Skip to content

Fix CEF flicker when resuming rendering - #5408

Open
Zephkek wants to merge 2 commits into
multitheftauto:masterfrom
Zephkek:fix/cef-resume-flicker
Open

Zephkek wants to merge 2 commits into
multitheftauto:masterfrom
Zephkek:fix/cef-resume-flicker

Conversation

@Zephkek

@Zephkek Zephkek commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Pausing rendering hid the browser. When it is shown again CEF replays the last frame composited before the pause, once because the video capturer restarts and once more for the Invalidate call, and that stale frame lands on the texture before the real one.

Paused browsers now stay visible and simply stop receiving begin frames. A script change (JS, resize, page load, the pause call itself) still gets two frames while paused, so the texture is always current when rendering resumes.

Fixes #5371

Test plan

Repro resource from #5371: start vr_ui and cef_flicker, press m repeatedly. The dialog opens in its current state with no stale frame. Hover after resume still updates (#5154).

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

Pausing hid the browser, so resuming restarted the viz video capturer
and Invalidate asked for a refresh frame. Both replay the last frame
composited before the pause, and the capture oracle then delays the
first real frame. Stale hover and layout state showed for a moment.

Keep the browser visible and only stop feeding it begin frames. Pause
and resume each send one begin frame so the texture holds the final
page state while paused and updates right away on resume.
@FileEX

FileEX commented Sep 16, 2026

Copy link
Copy Markdown
Member

The issue still isn't fully fixed. It no longer flickers every time, but it still happens occasionally.
https://www.image2url.com/r2/default/videos/1789553537860-4254bf69-7d57-4402-bc1d-96df67b6d2c5.mp4

On top of that, the second interface still loads with the old size when opened, which doesn't happen in 1.6.
https://www.image2url.com/r2/default/videos/1789553635806-b6096acb-238c-40da-b0bd-5566b6202be6.mp4

	executeBrowserJavascript(browserElement, 'openWindow("addObject");');

	setTimer(function()
		executeBrowserJavascript(browserElement, 'setObjectEditorHeight('..(screenY * 0.95)..');');
	end, 50, 1);

A paused browser got no frames at all, so whatever a script changed
right before or during the pause was only painted after resume, with
the old frame showing first. Script changes now request two frames
even while paused, so the texture is current when rendering resumes.
@Zephkek

Zephkek commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

ok looked into it, it's just a small bug in the pause path. a paused browser got no frames at all, so the closeWindow and the mouse move you send right before pausing sometimes never got painted, and the old dialog was still sitting in the texture when you resumed. pushed a fix, a paused browser now gets a frame whenever a script touches it (js, resize, page load), so the texture is always current when you unpause.

the size thing is a different story. your addObject window mounts at its default 750px and only grows when the 50ms timer runs setObjectEditorHeight, so there is a real 750px frame in between and now it gets painted. on 1.6 the first frame after WasHidden(false) showed up late enough that the timer had already run. easiest fix on your side is passing the height into openWindow. with this patch you can also open and resize it while still paused and unpause a frame or two later, the texture is already right by then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CEF flickering when resuming rendering

2 participants