Skip to content

fix(ios): set the view's default props for RN 0.87+ - #29

Merged
riteshshukla04 merged 4 commits into
margelo:mainfrom
SectionTN:fix/ios-view-default-props
Nov 11, 2026
Merged

riteshshukla04 merged 4 commits into
margelo:mainfrom
SectionTN:fix/ios-view-default-props

Conversation

@SectionTN

@SectionTN SectionTN commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #27.

On React Native 0.87 and later, debug iOS builds crash on the first canvas. RN checks that a view sets its own default _props, and since 0.87 that check fails for HybridTgfxViewComponent, which never set them. nitrogen 0.37 sets them, so this regenerates the code with nitrogen 0.37.2. The new code needs react-native-nitro-modules 0.37.2 or later, which is the new peer minimum.

Nitro 0.37 also calls onDropView when React Native puts a view in its reuse pool. HybridTgfxView released the Metal window there, and a reused canvas drew nothing. Now onDropView waits one main-queue turn and prepareForRecycle cancels the release. A pooled canvas keeps its window as before.

In an RN 0.88.1 app, 0.2.0 crashes and this branch renders. The example app's harness passes on iOS, and Android has no new failures. I also moved the benchmark app to 0.37.2 but didn't build it.

Nitro 0.37 calls onDropView before React Native pools a view, not only
when the view is destroyed (margelo/nitro#1494). onDropView releases
the GPU window and invalidates the display link, and nothing started
them again, so a canvas taken back from the pool never drew.

didMoveToWindow now starts a new display link when a dropped view gets
a window, and the next draw binds a new window. The bind flag is also
reset on the render queue, because a draw queued before the drop could
bind a window that releaseWindow then dropped.
@vercel

vercel Bot commented Nov 10, 2026

Copy link
Copy Markdown

@SectionTN is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

@SectionTN SectionTN changed the title fix(ios): set the view's default props for React Native 0.87+ fix(ios): set the view's default props for RN 0.87+ Nov 10, 2026
React Native 0.87 made ViewShadowNodeProps an alias of ViewProps.
RCTViewComponentView asserts that a subclass sets its own default props
in its constructor, and the default the base class sets used to be a
subclass of ViewProps, so the check passed for every view. Since 0.87
it fails for HybridTgfxViewComponent, which never set _props, and a
debug build throws on the first canvas.

nitrogen 0.37.0 sets _props in the generated init. Its view code uses
the props API that react-native-nitro-modules 0.37 added, so 0.37.2 is
now the peer minimum, and both apps move to it.
@SectionTN
SectionTN marked this pull request as ready for review November 10, 2026 13:49
@SectionTN
SectionTN marked this pull request as draft November 10, 2026 14:35
Nitro 0.37 calls onDropView right before prepareForRecycle when React
Native pools a view. Releasing the Metal window there made a reused
canvas build a new one, and its first frame on that window sometimes
took 0.8 s, which left the previous scene on screen.

onDropView now waits one main-queue turn before it releases, and
prepareForRecycle cancels the release. A pooled canvas keeps its window
and display link as it did before Nitro 0.37, and a view dropped
without being pooled still releases everything. The display link
restart in didMoveToWindow stays for a released view that gets a
window again.
@SectionTN
SectionTN marked this pull request as ready for review November 10, 2026 15:18
@riteshshukla04
riteshshukla04 merged commit a0fb473 into margelo:main Nov 11, 2026
7 of 8 checks passed
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.

iOS crash with RN 0.88

2 participants