SDL slowness while scrolling in Firefox on X11

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
SDL slowness while scrolling in Firefox on X11
by on (#119047)
Scrolling in Firefox in GNOME/Compiz (with at least the nouveau driver) makes SDL_Flip() and SDL_RenderPresent() (SDL2) extremely slow for me, to the point of only being able to do ~30 FPS with everything removed but those calls. Chromium doesn't cause nearly the same slowdown. Might be related to the way Firefox draws the screen, if it needs to DMA a lot of data or causes some lock to be held for a long time, but that's just speculation.

Anyone else seeing the same thing? Might need to drop SDL_Flip() flip calls or do the emulation in a separate thread that signals the rendering thread to get around it I guess. Currently it causes bad sound stuttering (especially with SDL2) as sample generation is done in the same thread that SDL_Flip()s (and yeah, that's arguably poor practice anyway).
Re: SDL slowness while scrolling in Firefox on X11
by on (#119048)
Using software rendering doesn't help btw, so I'm guessing it's hitting a bottleneck in the 3D-accelerated desktop.
Re: SDL slowness while scrolling in Firefox on X11
by on (#119065)
Firefox > Preferences > Preferences > Advanced > General > Browsing
Turn OFF smooth scrolling, as I did several Firefox versions ago, and see if that fixes anything. I couldn't even find a smooth scrolling setting in Chromium, so I have a feeling that might be the reason for the difference.
Re: SDL slowness while scrolling in Firefox on X11
by on (#119068)
Also, see what happens if you try a non-compositing windowmanager.
Re: SDL slowness while scrolling in Firefox on X11
by on (#119070)
tepples wrote:
Firefox > Preferences > Preferences > Advanced > General > Browsing
Turn OFF smooth scrolling, as I did several Firefox versions ago, and see if that fixes anything. I couldn't even find a smooth scrolling setting in Chromium, so I have a feeling that might be the reason for the difference.


Might've made it marginally better, but it's still worse than Chromium.

Another thing I just noticed really slows it down is bringing up the translucent Ubuntu menu in Unity (regardless of whether it overlaps the window). As I want my emu to work well on common setups without tweaking, I'll probably go with a separate rendering thread. I could have it drop the new frame if the old one hasn't finished uploading.

lidnariq wrote:
Also, see what happens if you try a non-compositing windowmanager.


Would be an interesting experiment, as long as I don't mess up my install somehow. :)
Re: SDL slowness while scrolling in Firefox on X11
by on (#119071)
ulfalizer wrote:
Another thing I just noticed really slows it down is bringing up the translucent Ubuntu menu in Unity (regardless of whether it overlaps the window).
Yeah, that's definitely the fault of the compositor, albeit exacerbated by the nouveau driver. Not that telling people to switch to a less awful desktop environment is a serious option...
Re: SDL slowness while scrolling in Firefox on X11
by on (#119149)
Split off emulation and SDL stuff into separate threads, and now the audio runs fine even though video framedrops like crazy with the Ubuntu menu open. Another thing it hates is when you place the window so it overlaps the border between two monitors. Robust stuff... :P
Re: SDL slowness while scrolling in Firefox on X11
by on (#119302)
I know, right? I can't tell you how many times I need to play SMB with the window half way between two monitors with the menu screen overlay open. It's so inconvenient and I'm considering moving to something else until SDL2 gets its act together.
Re: SDL slowness while scrolling in Firefox on X11
by on (#119340)
Drag wrote:
I know, right? I can't tell you how many times I need to play SMB with the window half way between two monitors with the menu screen overlay open. It's so inconvenient and I'm considering moving to something else until SDL2 gets its act together.


It happens with SDL1 too, and it's more about general robustness and not having sound crap out whenever a menu is opened or whatever.
Re: SDL slowness while scrolling in Firefox on X11
by on (#119346)
I really would have thought that proper xrandr 1.2+ support would have fixed cross-head problems: internally both CRTCs should be set up to read from the same linear framebuffer without any memory discontinuities that would cause performance problems...

I suppose SDL could be being Too Smart and ignoring the xrandr data for just the xinerama data and splitting the texture into two? I wonder if you made an xinerama-ignorant build of SDL whether it would improve performance.
Re: SDL slowness while scrolling in Firefox on X11
by on (#119348)
Played around with the SDL_VIDEO_X11_XINERAMA and SDL_VIDEO_X11_XRANDR environment variables, but no setting seems to eliminate the slowdown. Could be a problem below the SDL level.

The SDL_VIDEO_X11_XRANDR documentation says "by default SDL will not use XRandR because of window manager issues" by the way, but running with SDL_VIDEO_X11_XRANDR=1 makes no difference.