fix(ios): redraw when the view re-enters a window - #4049
Open
invivek26 wants to merge 2 commits into
Open
Conversation
A SkiaUIView that draws while its screen is detached from the window (an inactive tab in a react-native-screens container, a covered stack screen) never presents that frame, and nothing asks it to draw again when the screen comes back, so it keeps showing the last frame it presented before it left. Static canvases whose content changed while offscreen come back stale. Redraw the current picture in didMoveToWindow, and present that frame with presentsWithTransaction so it lands in the same Core Animation transaction as the view's return rather than one frame later.
invivek26
force-pushed
the
fix/ios-redraw-on-window-attach
branch
from
September 4, 2026 18:23
87e064e to
9396d39
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.
Problem
A
SkiaUIViewthat draws while its screen is detached from the window keeps presenting the last frame it showed before it left. Typical case: a static canvas inside an inactive tab of a react-native-screens container. The app changes theme, the canvas re-renders and draws while the tab is offscreen, that frame is never presented, and when the tab comes back the view still shows the old theme. Nothing invalidates it again, so it stays stale until the screen remounts.layoutSubviewsdoesn't help because the frame is unchanged.Fix
Override
didMoveToWindowand redraw the current picture when the view is back in a window. Present that frame withpresentsWithTransactionand wait until the command buffer is scheduled, so it lands in the same Core Animation transaction as the view's return. Without that, the frame presents one vsync later and the stale contents flash for one frame.Verification
iPhone 17 Pro simulator, iOS 26.5, React Native 0.86.3, react-native-screens 4.26.2, with a canvas whose colors change while its tab is inactive.
presentsWithTransaction: correct on the first frame.iOS only. macOS is excluded since
didMoveToWindowis UIKit.