Fix white flash when takePlayerScreenShot is used with CEF browsers#5004
Fix white flash when takePlayerScreenShot is used with CEF browsers#5004QueryOfficial wants to merge 2 commits into
Conversation
…e clearing methods This commit removes the OnPreScreenshot, OnPostScreenshot, and ClearTextures methods from CWebCore and CWebView classes. The changes streamline the code by eliminating unused functionality related to screenshot processing and texture management, improving overall maintainability.
|
It may have been intended by the commit which originally introduced these hooks to intentionally exclude CEF webview contents from screenshots captured by this function, as they can reasonably be considered part of the GUI and may contain more sensitive information than the game scene (usernames or passwords being typed, etc.). From your PR description alone, it's not clear to me whether you've considered that potentially intentional behavior, or whether your change causes Could you elaborate on those considerations? |
|
Good point. I did consider whether the old behaviour was intentional. To clarify my planned approach: with withCef = true, the screenshot includes the browser as it appears on screen. With withCef = false, the capture is taken as if the browser were not there, and the player never sees a flash. That follow-up is ready locally but not committed yet — I wanted to align on the intended behaviour first. Does MTA want browser content to never appear in screenshots at all? If so, I can adjust accordingly in a follow-up commit. |
While the idea of censoring certain parts on the clients screen before taking a screenshot is noble, its outdated nowadays. Especially with the tools given in lua to capture all elements (including mta guis) on screen with other means, this "security" approach is kinda outdated. And given certain servers render CEF on whole screen to draw HUD elements, I dont see any other solution than removing that censoring if this is the root cause. |
|
Same here — I agree the censorship should go, which is why this PR removes it. I kept the follow-up uncommitted because I still think it's worth discussing. If preferred, I can add a
Happy to proceed either way based on consensus here. |
Summary
Remove the pre/post screenshot hooks that cleared live CEF render targets before
takePlayerScreenShotcapture. The back buffer is now grabbed as-is afterDrawPreGUIQueue, eliminating the visible white flash when a CEF browser is on screen.Also removes the now-unused
OnPreScreenshot,OnPostScreenshot,ClearTextures, andClearTexturecode paths.Motivation
When the server calls
takePlayerScreenShotwhile a client has a CEF browser displayed viacreateBrowser+dxDrawImage, the player's screen briefly flashes white on every capture.The old flow cleared live CEF textures to white (
0xFF) before reading the back buffer, then triggered an asyncInvalidateto repaint them. That touched the same textures used for on-screen rendering in the same frame, so the flash was visible to the player.This change captures the back buffer without modifying live CEF textures. Screenshot upload continues to work; only the visible flash is removed.
Fixes #4955
Test plan
Create a CEF browser on the client and draw it with
dxDrawImage. CalltakePlayerScreenShotfrom the server repeatedly and confirm no white flash appears on the client.Confirm the server still receives the screenshot with correct game content.
Test downscaled capture with
takePlayerScreenShot(player, 320, 240, ...).Regression: F12 local screenshot still works.
Regression: alt-tab / minimized client still returns
MINIMIZED/DISABLEDresponses as before.Checklist