browser: Reduce spurious rendering and lock contention#56
Open
Yabuku-xD wants to merge 1 commit into
Open
Conversation
f222f99 to
74ef763
Compare
Four targeted improvements to the browser crate's rendering pipeline: 1. Gate FrameReady on suspension state (tab.rs): Skip emitting TabEvent::FrameReady for suspended tabs. CEF already stops rendering hidden browsers, but this prevents any in-flight frames from propagating cx.notify() after suspension. 2. Gate FrameReady cx.notify() on surface visibility (browser_view.rs): Only trigger a re-render when BrowserSurfaceState is Visible. In-flight FrameReady events queued just before a mode switch no longer cause spurious layout work on the hidden browser view. 3. Split RenderState Mutex (render_handler.rs, tab.rs, client.rs, life_span_handler.rs): Extract current_frame into its own Arc<Mutex<Option<CVPixelBuffer>>> separate from the geometry fields (width, height, scale_factor). CEF's view_rect and screen_info callbacks no longer share a lock with the 60fps frame write path, eliminating cross-contention between geometry queries and frame writes. 4. Compute pinned_count once per render pass (tab_strip.rs, browser_view.rs): Both render_tab_strip and render_sidebar previously ran an independent O(n) tab scan to count pinned tabs. The count is now computed once in the render() method via a pinned_tab_count() helper and passed as a parameter to both render methods.
74ef763 to
e32496a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Four targeted, low-risk improvements to the browser crate's rendering pipeline — no new dependencies, no behavior changes, purely less wasted work:
FrameReadyon suspension (tab.rs): Skip emittingTabEvent::FrameReadyfor suspended tabs, matching the existingis_suspendedguard on all other events.FrameReadynotify on surface visibility (browser_view.rs): Only callcx.notify()fromFrameReadywhensurface_state == Visible. In-flight frames queued just before a mode switch no longer trigger layout work on the hidden browser view.RenderStateMutex (render_handler.rs,tab.rs,client.rs,life_span_handler.rs): Extractcurrent_frame: Option<CVPixelBuffer>into its ownArc<Mutex<...>>. CEF'sview_rect/screen_infogeometry callbacks no longer share a lock with the 60fpson_accelerated_paintwrite path. Geometry queries and frame buffer writes now operate on independent locks — no contention between them.pinned_countonce per render (tab_strip.rs,browser_view.rs): Bothrender_tab_stripandrender_sidebarpreviously performed independentO(n)scans over all tabs to count pinned ones. Apinned_tab_count()helper is now called once inrender()and passed as a parameter to both methods.Test plan
cargo check -p browserpasses with no errorscargo check -p workspace -p browserpassesRelease Notes: