Eiim / Chokistream

A from-scratch re-implementation of Snickerstream
GNU General Public License v2.0
30 stars 1 forks source link

Significant lag/latency compared to other NTR viewers when using NTR-HR #29

Closed flanter21 closed 7 months ago

flanter21 commented 8 months ago

Describe the bug Picture renders at a seemingly capped 40fps. This means as the stream continues, the latency between whats on the 3ds and pc becomes much larger. The framerate also seems to be choppier on the Mac (but that might just be my eyes). Also seems worse when not using separate windows.

Steps taken

Versions/settings

Take screenshots of the Chokistream settings, including mod settings, and put them here. IMG_8764 2 Difference clearly seen when using 240p test suite in snes9x. FPS ends up reaching 0 after a few minutes. Default settings

Additional context Add any other context about the problem here.

Eiim commented 8 months ago

I'm not able to reproduce, but I'm also only getting 20fps in the lag test. On the main menu I was able to reach 45-50fps though, and it seemed fine. I'm definitely interested in this, but I'm not sure what other information you can provide to help me recreate it. Other than, is that a N3DS or N3DS XL? The differences are very slight but maybe there's a bug/feature with NTR-HR such that it functions differently between the two? IMG_20240112_135235

Eiim commented 8 months ago

I'll ping @xzn on this, in case they have any useful insight.

xzn commented 8 months ago

I can't reproduce this on Windows 11 either, was thinking it's a Mac only problem but OP said Windows 11 and Mac Sonoma.

It could be that NTR sending more than the 40 fps that is displayed somehow causing a problem.. How is it possible that Chokistream queues up seconds worth of frames though? Or is it the wifi card being funny maybe?

Edit: Maybe UDP packets are being buffered by the OS and not received fast enough somehow.. Don't know why though?

P.S.:

I did found a bug (not sure if related to this one) while looking into this.. ( updated version here edit: okay this one has a new bug try the next release please, sorry! )

(Basically wrong variables were read if frames were skipped, and stale values were used if core count were changed, so sometimes fps is half of what it could be when number of encoding core is set to 2)

I don't know why you are only getting 20 fps though? (Quality 75 QoS 16 and I get 45 fps even with just one core). @Eiim what's your wifi setup just wondering?

Eiim commented 8 months ago

I admittedly haven't poked around at the NTR code for a while, so I forgot that we do actually have a frame buffer for NTR, so if the computer isn't able to render frames fast enough, that could slowly fill up, and maybe as it consumes more RAM it slows the whole system down? Honestly we probably should get rid of the NTR frame buffer, we don't use one for HzMod/Chirunomod and it could cause these kinds of desyncs without much benefit. I'll build a fork without it and we can see if that works.

As for the 20fps thing, I'm on a fairly high-end router, ~300Mbit I believe, so it shouldn't be a bottleneck compared to the 3DS WiFi chip. I had QoS at 26 before but it's the same at 16, and I fiddled with priority factor but still couldn't get it above 20 for that particular test. Snes9x in general seems pretty slow with NTR-HR (although I'm not sure if that's the same with regular NTR 3.6 or not)

Eiim commented 8 months ago

@flanter21 Try this version and see if it works for you.

chokistream.zip

xzn commented 8 months ago

@Eiim is your router set to 2.4 GHz only (i.e. 5 GHz disabled)? on 5 GHz/2.4 GHz mixed I usually get around 5 Mbps (iirc) on 3DS. 2.4 GHz b/g only then I could get up to 18 Mbps without much issue.

Eiim commented 8 months ago

@xzn Yes, I have both 2.4 and 5 GHz available.

flanter21 commented 8 months ago

@eiim @xzn I think I've got it. It's the scaling in chokistream not the streaming function. I had the top screen set to 3.0 and would get the lag, but when I set it back to 1.0 it works perfectly. I'll check out the version you put here though and edit this reply @eiim

Edit: I think the frame counter is broken btw.

image
Eiim commented 8 months ago

@flanter21 I'm guessing the frame counter being broken is with the version I sent? This should fix it. Make sure you check with scaling at 3.0 as well to see if that's better. It might still have decreased framerate but it shouldn't desync.

Edit: fix file

chokistream.zip

chokistream.zip

flanter21 commented 8 months ago

@eiim the build you sent here fixes the lag although it seems impossible to get more than 30-ish fps and while it doesn't appear to have the issue, it does still seem to have more latency compared to other clients. I'm getting about ~12 frames of delay on this compared to 4to6 with kitkatslim (in Wine). The latency seems to be higher with at higher scaled resolutions.

Edit: it seems to average 20fps even at 1.0 scale whereas the release version does get 60fps at 1.0 scale. Also i forgot but you did ask earlier; i use a n3dsxl

Edit 2: v2.0.1 does actually seem to have comparable latency to kitkatslim, so this extra lag might be because of the changes you made in this build.

Eiim commented 8 months ago

I'm going to leave this open for the moment but I added some new performance tickets here and here.

flanter21 commented 8 months ago

@eiim cool stuff. Thank you!

ChainSwordCS commented 7 months ago

That commit should hopefully fix the problem of being locked to 30 FPS. Make sure that, in the NTR Settings, the "QoS" is set high enough. Setting it around 15-20 should be good.

Here's the compiled chokistream.jar for testing: https://github.com/Eiim/Chokistream/actions/runs/7812201589

Let us know if there are still any issues. I'm gonna be looking into the latency issue soon.

ChainSwordCS commented 7 months ago

Haha just kidding, I forgot to test at 3x screen scale. At any rate that should be an improvement at 1x scale, but 3x scale won't see that until scaling performance is improved.

Eiim commented 7 months ago

Scaling performance improved in e6c065b

Eiim commented 7 months ago

Marking as closed in v2.1, let us know if there are still issues.