<FromGitter>
<oprypin:matrix.org> it is indeed *relatively* straightforward but not trivial. and then also difficult how to present the results.. unless there are widely used standards that make it obvious..?
taupiqueur has quit [Quit: taupiqueur]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Client Quit]
taupiqueur has joined #crystal-lang
<FromGitter>
<moe:busyloop.net> oprypin (https://matrix.to/#/@oprypin:matrix.org): hmm true. i guess doing it right will take a bit more work than my naive approach. after some looking it seems like `gcov` is the big daddy in the space. they seem to support a JSON format (search for "json" in https://man7.org/linux/man-pages/man1/gcov.1.html) which is supported by a variety of report generators / CI tools (e.g. jenkins or lcov;
<FromGitter>
<moe:busyloop.net> well, probably not the highest prio in the grand scheme of things. ⏎ i wonder if the instrumentation could perhaps also help with error messages tho. (line numbers tend to be all over the place in recent crystal versions for me when macros get involved)
<FromGitter>
<moe:busyloop.net> fwiw, it looks like there are various degrees of "doing it right". e.g. go-lang apparently only does line-coverage https://gitlab.com/stone.code/scov#using-go - so that may be good enough for a future first version in crystal as well
ejjfunky0 has joined #crystal-lang
notzmv has joined #crystal-lang
notzmv has quit [Ping timeout: 256 seconds]
taupiqueur has quit [Ping timeout: 256 seconds]
taupiqueur has joined #crystal-lang
taupiqueur has quit [Ping timeout: 256 seconds]
taupiqueur has joined #crystal-lang
<FromGitter>
<y8> @naqvis I'm writing wasm interpreter in crystal. It's stack based ISA for abstract "hardware". There is tons of instructions with different shapes: bytesize, how many values it pops/pushes on stack, immediate values arity, memory/locals/globas access & etc. Almost all instructions interact with stack, so I decided to specialize them using generic module "inheritance" based on "stack arity". ⏎ ⏎ What I don't
<FromGitter>
... like in current approach, is that vm instance is passed to context where instructions are computed, even if they don't require VM. But I can live with it
<FromGitter>
<y8> Is there a way to add element to array and get its new index?
<FromGitter>
<y8> At the same time I mean, without getting size and all
<FromGitter>
<naqvis> `Array#size` is just a simple wrapper against internal variable `@size`, so calling `size` on array is not going to traverse the whole to return the count. `Array#push` returns the same array object, so you can get the index via ⏎ ⏎ ```arr = [1,2,3] ⏎ index = arr.push(4).size - 1 # => 3``` [https://gitter.im/crystal-lang/crystal?at=62125749f43b6d783fc6b314]
<FromGitter>
<moe:busyloop.net> why does String not have a ctor that takes a String? 🤔
<FromGitter>
<Blacksmoke16> fwiw, the numeric constructors essentially just call like `.to_i32` on whatever you pass it
<FromGitter>
<Blacksmoke16> for string that would be `.to_s`
<FromGitter>
<moe:busyloop.net> yup. it's not a big deal, just surprised i had to make a special case for String in my little env-var macro
<FromGitter>
<Blacksmoke16> could always just monkey patch in a constructor to do it
<FromGitter>
<moe:busyloop.net> yeh that's what i did first, but then took it out again. probably not gonna release this one as a shard anyway, but not a fan of patching base-classes in general.
<FromGitter>
<Blacksmoke16> if you do, might not be a bad idea to name it something else, like `.from_env_value` or something
<FromGitter>
<moe:busyloop.net> yeh at the moment i just do `{{type}}.new(str_val)`
<FromGitter>
<moe:busyloop.net> yeh it's fine i'm good, just caught me by surprise
<FromGitter>
<Blacksmoke16> 👍
notzmv has joined #crystal-lang
<FromGitter>
<naqvis> > why does String not have a ctor that takes a String? 🤔 ⏎ ⏎ String is immutable, so technically speaking calling ctor with String is just going to return a copy of the same. So it really doesn't make any difference to either assign string obj to new obj or call it via ctor.
<FromGitter>
<moe:busyloop.net> yup, probably a bit of a special case here. was just surprised it doesn't just return a cpoy
<FromGitter>
<moe:busyloop.net> https://carc.in/#/r/csu6 - in hindsight guess it would be nicer to sneak in a "Converter"-class anyway, or monkeypatch `#from_env` like blacksmoke said rather than relying on `#new`. but anyweh, good enough for me for now.
ejjfunky0 has quit [Remote host closed the connection]
ejjfunky has quit [Ping timeout: 256 seconds]
<SamantazFox>
Blacksmoke16: Ok, so I tried to compile crystal while using got bisect, and uhhhh... It doesn't work, but in a different manner than what I was having on crystal 1.3.0
<FromGitter>
<Blacksmoke16> oh?
<SamantazFox>
I'm getting 502 bad gateway from ngninx
<SamantazFox>
nginx*
<FromGitter>
<Blacksmoke16> is the server actually running?
<SamantazFox>
yeah, because the favicon shows up.
<SamantazFox>
it's the only thing that works)
<FromGitter>
<Blacksmoke16> would it be possible to extract the part with the error to a single file that returns exit code 1 or 0?
<FromGitter>
<Blacksmoke16> versus long running server
<SamantazFox>
nope, because there are many layers between the client (the browser) and said code
<FromGitter>
<Blacksmoke16> rip
<SamantazFox>
There is Kemal, the `before_all` logic, the routing, etc...
<FromGitter>
<Blacksmoke16> guess you could always just do it the hard way. I.e. do what bisect does but manually
<SamantazFox>
yep, but that probably won't work either
<SamantazFox>
I'm thinking that my home-made compiler is definitely missing something.
<FromGitter>
<Blacksmoke16> i.e. assert you have the issue on 1.3.x and not on 1.2.x then pick the commit halfway between, see if you still have an issue, then go halfway between 1.2.x and the last commit
<SamantazFox>
that's what I'm doing!
<FromGitter>
<Blacksmoke16> oh well, step 1 would be to ensure you can actually use locally compiled version to run it
<FromGitter>
<Blacksmoke16> are you doing like `make clean && make all && ./bin/crystal app.cr`?
<FromGitter>
<Blacksmoke16> because thats all there should be to it
<SamantazFox>
`cd crystal.git; make clean && make clean_cache && make crystal release=1 progress=true; cd ../invidious.git; make RELEASE=0 DISABLE_QUIC=1 && make deploy`
<SamantazFox>
(I've edited my Makefile to point to `<HOME>/crystal.git/bin/crystal` instead of just `crystal`)
<FromGitter>
<Blacksmoke16> oh jezz, well i dont think you need to compile crystal in release mode, that would take like 10-20min
<FromGitter>
<Blacksmoke16> `cd crystal.git; make clean && make all; cd ../invidious.git; make RELEASE=0 DISABLE_QUIC=1 && make deploy` id just try this
<SamantazFox>
I already did!
<FromGitter>
<Blacksmoke16> and there's not compiler/runtime errors?
<FromGitter>
<Blacksmoke16> apparently im missing a `config/config.yml` file?
<FromGitter>
<Blacksmoke16> oh nvm, theres a sample one
<SamantazFox>
Oh, yeah...
<SamantazFox>
I'd recommend to remove all routes but the video playback ones (they're defined in the main source file)
<SamantazFox>
Otherwise, you'll need a Postgres DB
<FromGitter>
<Blacksmoke16> thats fine, compose file is easy enough :0
<FromGitter>
<Blacksmoke16> ;)
<SamantazFox>
ha, nice ^^
<FromGitter>
<Blacksmoke16> alright, so whats the issue exactly? i went to that url and am watching a video
<SamantazFox>
with what version of crystal?
<FromGitter>
<Blacksmoke16> 1) 3.2
<SamantazFox>
ok, check your devtools
<SamantazFox>
there are multiple queries failing
<SamantazFox>
Note that it doesn't always prevent playback (E.g I can watch videos fine on Firefox and Chrome-based browsers, but that makes Safari go "nope")
<FromGitter>
<Blacksmoke16> you mean http requests?
<SamantazFox>
if you look at the console, the VideoJS player gets confused
<SamantazFox>
(I've made a fix on my own instance to solve that DASH playback problem, which breaks the non-DASH playback instead).
<FromGitter>
<Blacksmoke16> okay yea, that one fails and are a lot more requests
<SamantazFox>
Yeah!
<SamantazFox>
And so, what I've done is to remove the ugly loop in `srv/invidious/routes/video_playback.cr` and instead just copy the data returned by Google servers.
<FromGitter>
<Blacksmoke16> okay so using 1.2.2, i still get a lot of requests, but none of them fail
<SamantazFox>
yeah, that's normal. DASH works by very small data chunks
<SamantazFox>
Where as "normal" video (non-DASH) is streamed like a normal large file.
<SamantazFox>
When I remove the loop (https://github.com/iv-org/invidious/pull/2900/files, but comment out the `2.times`) this has the effect of closing the connection, and the browser naturally requests the next byte range.
<SamantazFox>
And that's where I hit the "double `FIN`" problem.
<FromGitter>
<Blacksmoke16> let me play with bisect a bit
<FromGitter>
<Blacksmoke16> hmm well first commit it just doesnt work at all 🤔 ⏎ ⏎ > The media could not be loaded, either because the server or network failed or because the format is not supported.
<SamantazFox>
yup, seems familiar xD
<SamantazFox>
what do your devtools say?
<FromGitter>
<Blacksmoke16> failure on `/api/manifest/dash/id/...`
<FromGitter>
<Blacksmoke16> > TTP error: status code undefined, net::ERR_EMPTY_RESPONSE
<FromGitter>
<Blacksmoke16> HTTP*, also got that in console
<SamantazFox>
yup, that's the beginning of my problem!
<FromGitter>
<moe:busyloop.net> it looks like you (or kemal) are trying to set that header "too late". previously it may have been ignored, but now it checks if the IO is still open
<SamantazFox>
on our side, we set the headers before `IO.copy` so that can't be here. So yeah, maybe kemal?
<FromGitter>
<Blacksmoke16> reminder headers are sent as soon as you write *any* data to the response
* FromGitter
* moe:busyloop.net can already hear that bug shaking in his shoes
<SamantazFox>
Blacksmoke16: yeah, I know!
<SamantazFox>
And they're exactly what I'd expect
<SamantazFox>
So I don't get how that makes the response to be terminated early (like 2kb early)
<SamantazFox>
And I can't find where `check_open` is definied, argh!
<FromGitter>
<moe:busyloop.net> another wild guess: this is streaming/proxying from another IO, right? possibly a *different* error happens first, and kemal does something weird like trying to render an error-page on top of a response that's already in progress?
<SamantazFox>
Yeah, we're proxying from the client's response IO. As for the errors, any error would have already terminated the function, and that proxying code shouldn't be reached.
<SamantazFox>
any prior error*
<SamantazFox>
All of these `client.get` blocks are rescued, and (currently, on my test server) a backtrace should be printed in the event where the `rescue` branch is reached (which doesn't happen apparently, as I have no logs).
<FromGitter>
<moe:busyloop.net> hm yea, sounds unlikely then. but may be worth a poke at how much buffering is at play. e.g. something like "response complete and buffered, but an exception bubbles up before it's actually flushed".
<FromGitter>
<moe:busyloop.net> do those 0-byte replies have the right headers or are those also busted?
<SamantazFox>
I don't have server logs for those, but I think that yes, headers are somewhat valid, as the tested browser (Safari on macOS) is then requesting the right URL (so at least the `Location` header is untouched).
<SamantazFox>
you got me thinking: I'm going to try putting a `.flush` call after my `IO.copy`. That could do the trick.
<FromGitter>
<Blacksmoke16> > a backtrace should be printed in the event where the rescue branch is reached ⏎ ⏎ Pretty sure this just doesnt magically happen
<FromGitter>
<Blacksmoke16> unless you manually log it, or it reaches something that does or prints the backtrace. I.e. some built in exception handler or it goes unhandled