8 ms·
The effect of web browser “Input Lag” in HTML5 games (2017)
- modeless 6y agoFun fact: DWM enforces >1 frame of input lag on every Windows application running in a window. It is impossible to do better than 1 frame. But DWM itself does better: when you drag windows around they apparently stick to the mouse cursor exactly, which would be zero frames of latency. How do they do it? By cheating: they delay the mouse cursor by one frame, only while you are dragging a window. So the latency is still there but less obvious because it doesn't cause a difference between the cursor and window motion.
- jancsika 6y agoClever. If we can just teach audiences to clap one sixteenth-note later than usual then all live music could go completely digital!
- the8472 6y ago> It is impossible to do better than 1 frame. Exclusive fullscreen applications shouldn't need any compositing, surely they must be exempt from that.
- flohofwoe 6y agoThere's still plenty of latency sources on the way from he mouse hardware to the application's event handling code. The remaining way to the display just adds (more or less) latency on top - which isn't as important when it's just about the discrepancy of the mouse cursor and what's rendered beneath though. But the mouse cursor can use all sorts of special shortcuts, for instance the cursor is a hardware sprite which is updated and rendered indepedently from the rest of the "rendering pipeline" otherwise the cursor movement would feel laggy all the time.
- DaiPlusPlus 6y ago> for instance the cursor is a hardware sprite which is updated and rendered indepedently from the rest of the "rendering pipeline" otherwise the cursor movement would feel laggy all the time. While investigating cursor lag issues on my computer (which were caused by an errant Intel Optane card, of all things...) I read through Windows’ video driver documentation and I learned that while Windows does direct the mouse pointer completely independently of the DWM, there is no requirement that the cursor be rendered during scanout (like a hardware sprite) and it is permissible for a GPU to render the pointer to the framebuffer. In fact, there’s a lot that’s undefined by the specs - for example, I used to believe there was a hard limit of 127x127 on cursor sizes (based on the ICO file format) but it turns out there is no upper-limit on cursor sizes at all. If you set a huge cursor image (say, 1500x1500px) some GPUs do render it to the framebuffer but others do not (in my testing, newer Radeon cards behaved differently if the image was above ~600px, whereas with my Nvidia cards anything over 255x255 had a different mouse-acceleration curve, that was weird)
- modeless 6y agoYes, exclusive fullscreen mode applications are not running in a window, so they can have zero frames of latency (though almost all don't, for various reasons). I am not sure about borderless fullscreen mode, I think this may also have an optimization that can eliminate the 1 frame delay. But normal windows always get the delay. There is also a feature designed to let applications bypass this delay in windowed mode using GPU hardware overlays, however it needs GPU driver support and it is not supported on Nvidia or AMD drivers AFAIK. Basically nobody uses it.
- corysama 6y agoMS had a big push to completely deprecate exclusive fullscreen a couple years ago by improving borderless fullscreen to match it.
- Sunspark 6y agoI'm not sold that borderless fullscreen matches it. I can see the difference in video panning between exclusive fullscreen and borderless. Granted, it is not a huge difference, but it does exist. At the end of the day we continue become further and further abstracted from the hardware. Input lag on the display, input lag in the device, etc.
- modeless 6y agoVideo panning differences don't have anything to do with input lag. The only way fullscreen exclusive mode would change the appearance of video panning (bugs aside) is if it changed the mode of the monitor so the refresh rate matched the video frame rate (or equivalently used G-sync or Freesync to do the same).
- Sunspark 6y agoMadvr on Windows for video playback supports both windowed hardware overlay and fullscreen exclusive mode as options so that is one application which exists.
- 6y ago
- gruez 6y ago>Fun fact: DWM enforces >1 frame of input lag on every Windows application running in a window. It is impossible to do better than 1 frame AFAIK you can avoid it by using DXGI flip model. random page: >(DXGI) Flip Model is a new mode introduced in Windows 8 that makes the SwapChain work efficiently with the Windows DWM (Desktop Window Manager). Flip Model eliminates performance penalties normally associated with windowed mode rendering and introduces new methods to measure and regulate render latency. https://wiki.special-k.info/SwapChain https://wiki.special-k.info/SwapChain
- modeless 6y agoUnfortunately not. Flip model improves efficiency by removing one copy. However, the window contents are still composited into DWM's backbuffer just after vsync, so any rendering that happens during the frame is not displayed until the following frame. There is a flag DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING which can completely eliminate DWM's latency even for normal composited windows, but it only functions on systems with hardware overlays, which are not supported on Nvidia or AMD.
- DaiPlusPlus 6y ago> which are not supported on Nvidia or AMD What about Intel and Matrox? What about desktop compositors for Linux? And the macOS compositor? (Not that macOS is pleasant to use with a mouse...)
- modeless 6y agoIntel does support it. No idea about Matrox, but it seems like they don't make their own GPU chips anymore so probably not. I believe the situation is worse on most Linux compositors. MacOS I'm not sure of. I tested just now and it looks like at least one frame of latency on most things, and they don't implement the window dragging hack DWM does either.
- DaiPlusPlus 6y agoI note that touchpads (especially on Macs) seem to have considerably higher perceptual lag compared to mice, I think because of the smoothing necessary to make touchpads less fiddly - and as most macOS users are using a touchpad I imagine that contributes to less complaints about lag specifically because it would be difficult to pin-down.
- flohofwoe 6y agoMouse-to-display lag is even a hard problem in native desktop applications. TBH in this demo it doesn't look much worse than in a macOS, Windows or Linux UI application that renders through a 3D-API (and doesn't use all sorts of platform-specific hacks and tricks trying to minimize mouse latency).
- deleted 6y ago[deleted]
- newobj 6y agoCan anyone opine as to how these tests are achievable in a browser?
- DaiPlusPlus 6y agoThe “game” part at the top measures human lag time as a proxy for compositor lag, which is a crude approximation as it also includes monitor input lag as well. Other tests, including on the same site, are able to get the real-time hardware cursor position which the test code knows is ahead of the last-drawn cursor position and whatever position it’s drawing right now.