Skip to content

fix(ios): redraw when the view re-enters a window - #4049

Open
invivek26 wants to merge 2 commits into
Shopify:mainfrom
invivek26:fix/ios-redraw-on-window-attach
Open

fix(ios): redraw when the view re-enters a window#4049
invivek26 wants to merge 2 commits into
Shopify:mainfrom
invivek26:fix/ios-redraw-on-window-attach

Conversation

@invivek26

Copy link
Copy Markdown

Problem

A SkiaUIView that 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. layoutSubviews doesn't help because the frame is unchanged.

Fix

Override didMoveToWindow and redraw the current picture when the view is back in a window. Present that frame with presentsWithTransaction and 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.

  • Before: stale frame on return.
  • With the redraw alone: a one-frame flash of the stale contents.
  • With presentsWithTransaction: correct on the first frame.

iOS only. macOS is excluded since didMoveToWindow is UIKit.

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
invivek26 force-pushed the fix/ios-redraw-on-window-attach branch from 87e064e to 9396d39 Compare September 4, 2026 18:23
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.

1 participant