Repository navigation
[0.88] Keep the iOS renderer scheduler alive through instance shutdown - #60550
Open
gabrieldonadel wants to merge 1 commit into
Open
gabrieldonadel wants to merge 1 commit into
gabrieldonadel wants to merge 1 commit into
Conversation
gabrieldonadel
force-pushed
the
@gabrieldonadel/0.88-pick-1568
branch
from
December 4, 2026 14:11
d44a17c to
fc3f5c8
Compare
cortinico
approved these changes
Dec 4, 2026
cortinico
approved these changes
Dec 4, 2026
Fixes react#59721. During a normal bridgeless reload, `RCTInstance::invalidate` suspends the surface presenter before JS-thread cleanup runs. Suspension can destroy the renderer scheduler and its delegate proxy while the current JS task still has rendering updates capturing the proxy by raw pointer. Retain the scheduler through that cleanup, and clear its Objective-C delegate after stopping surfaces. Before dispatching cleanup, permanently remove its layout-animation run-loop observer on main. Scheduler destruction then stays in the same JS cleanup block as runtime destruction, with the scheduler released first. This prevents both an observer callout racing teardown and queued JSI handles outliving the runtime. It adds no per-rendering-callback guard, synchronous main wait, or JS-to-main-to-JS destruction round trip. Add three native lifecycle tests, the required CocoaPods Yoga header dependency for the scheduler import, and regenerated Apple API snapshots. [IOS] [FIXED] - Prevent a queued view command from accessing a destroyed scheduler delegate during a normal bridgeless reload Used the issue's public `Nezz/expo-repro` branch `repro/ReloadSchedulerCrash` (React Native 0.88.1), Xcode 27.1, and a dedicated iOS 27.1 iPhone Duo simulator. - Initial reproduction: unmodified prebuilt crashed in 20/20 reloads; unmodified source crashed in 10/10. An actual EXC_BAD_ACCESS report contained `Scheduler::uiManagerDidDispatchCommand` and `RuntimeScheduler_Modern::updateRendering` on the JS thread. - Final observer-detachment fix: 20/20 normal reloads acknowledged after removing all diagnostics, with no crashes or timeouts. - Final observer-detachment fix: 20/20 instrumented reloads during a five-second layout animation acknowledged, with no crashes or timeouts. All 20 processes recorded real animation ticks, observer removal on main, scheduler destruction on JS, then runtime teardown. No ticks occurred after observer removal. - After removing the diagnostics and rebuilding, another 5/5 animated reloads acknowledged with no crashes or timeouts. - Three native lifecycle tests pass in a clean build without diagnostics. They exercise real instance invalidation/presenter suspension with scheduler and JS-thread-manager collaborators replaced, covering observer removal on main, no callbacks while JS cleanup is pending, scheduler retention/release, and invalidation without a scheduler. Runtime/JSI behavior is covered by the app trials, not by these probes alone. - All 12 API snapshot validations pass with Doxygen 1.16.1; clang-format 21.1.2, Ruby podspec syntax, and `git diff --check` pass. An unpublished intermediate approach that released the whole scheduler on main after JS cleanup crashed in 1/20 animated trials while destroying queued JSI handles. The final fix instead detaches only the observer on main and preserves scheduler-before-runtime destruction in one JS cleanup block. Validation stages the production changes into the report's source-built 0.88.1 fixture; it is not a complete checkout-HEAD build or full RNTester suite. The reporter's iOS 26.5 environment, physical devices, and Release builds were not tested. This addresses normal off-JS-thread bridgeless reload, not a new policy for inline JS invalidation, standalone presenter suspension, nested main run loops, repeated invalidation, the legacy bridge, or the separate shared-animation backend. Rebased onto main `25d63d471a91cf9c2141bbe8dab6802eb73c2567`. Both commits applied without conflicts, and `git range-diff` confirms unchanged patches. All 12 API snapshots pass with Doxygen 1.16.1. Changed native sources pass clang-format 21.1.2, the podspec passes Ruby syntax checking, and diff checks pass. A fresh source build of the isolated React Native 0.88.1 fixture passes all three native lifecycle tests using the rebased test file and matching invalidation, observer-stop, and presenter-suspension methods. The earlier app reload trials remain prior evidence. Fresh runtime validation covers the three native lifecycle tests in that fixture, with scheduler and JS-thread-manager test probes. Checkout-head RNTester and device/Release execution remain outside this validation. Differential Revision: D129319362 Pull Request resolved: react#59754 (cherry picked from commit bfea95f) Signed-off-by: Gabriel Donadel <donadeldev@gmail.com>
gabrieldonadel
force-pushed
the
@gabrieldonadel/0.88-pick-1568
branch
from
December 5, 2026 14:39
fc3f5c8 to
b828604
Compare
This branch has not been deployed
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:
Backport of #59754 (
bfea95fb4cc) to0.88-stable, for pick request reactwg/react-native-releases#1568.It fixes an iOS crash on a normal bridgeless reload (#59721, related #58601): a queued view command could reach a destroyed scheduler delegate. Every
expo-updatesreloadAsync()goes through this reload, and the crash is in the prebuiltReact.framework.The pick sits on #59145 (
88d296713ca), which landed on0.88-stableas9c043dc11b0through reactwg/react-native-releases#1582. With it, the commit applies toRCTInstance.mm,RCTScheduler,RCTSurfacePresenter, the podspec and three API snapshots without changes. Two conflicts were resolved by hand:RNTesterPods.xcodeproj/project.pbxproj: kept the branch's lines and added only the fourRCTInstanceInvalidationTests.mmentries.RCTTurboModuleStringConversionTestsandRCTDevLoadingViewTestsare not on 0.88, so their lines stay out.ReactAppleFrameworksCxx.api: the snapshot does not exist on 0.88, so its change is dropped.Changelog:
[IOS] [FIXED] - Prevent a queued view command from accessing a destroyed scheduler delegate during a normal bridgeless reload
Test Plan:
git cherry-pick -xkeeps the original author.plutil -lintpasses on the resolvedproject.pbxproj.RCTInstanceInvalidationTests.mmexist on0.88-stable.RCTInstanceInvalidationTests.