Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<74896623764d3d01d2925fdcf30948f1>>
* @generated SignedSource<<c7480fceb75a5f614abf28813c501a54>>
*/

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi

override fun enableResizeObserverByDefault(): Boolean = false

override fun enableRuntimeSchedulerQueueClearingOnError(): Boolean = false
override fun enableRuntimeSchedulerQueueClearingOnError(): Boolean = true

override fun enableSchedulerDelegateInvalidation(): Boolean = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<7103d9c2fa3e2f152ce60b5dff12c0e4>>
* @generated SignedSource<<29904c9a4e11c71f7657c49f3f45a32f>>
*/

/**
Expand All @@ -25,8 +25,6 @@ public open class ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android :

override fun enableFlexboxAutoMinSizeInStrictMode(): Boolean = true

override fun enableRuntimeSchedulerQueueClearingOnError(): Boolean = true

override fun enableSchedulerDelegateInvalidation(): Boolean = true

override fun preventShadowTreeCommitExhaustion(): Boolean = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<0dcc09eb60ab85de9bc72410e93c2a1c>>
* @generated SignedSource<<374da5049c71e475cb3e5c2bfed87c9c>>
*/

/**
Expand Down Expand Up @@ -200,7 +200,7 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider {
}

bool enableRuntimeSchedulerQueueClearingOnError() override {
return false;
return true;
}

bool enableSchedulerDelegateInvalidation() override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<7341b28bb77aeeec670051149faeae04>>
* @generated SignedSource<<764568389a1ae8675638104ab3d96d4d>>
*/

/**
Expand All @@ -31,10 +31,6 @@ class ReactNativeFeatureFlagsOverridesOSSExperimental : public ReactNativeFeatur
return true;
}

bool enableRuntimeSchedulerQueueClearingOnError() override {
return true;
}

bool enableSchedulerDelegateInvalidation() override {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,19 @@ void RuntimeScheduler_Modern::updateRendering(
// internally; this call site stays a single invocation per tick.
if (resizeObserverDelegate_ != nullptr) {
// This delivers the observations to JS synchronously, so it is outside the
// error boundary of `executeTask`. Handle errors the same way here, so a
// throwing observer callback can't abort the remaining steps below.
// error boundary of `executeTask`. Report the error without going through
// `handleTaskError`: we are already inside the "update the rendering" step,
// so clearing the queues here would drop the pending rendering updates this
// step is about to drain, and a throwing observer callback would abort the
// remaining steps below.
try {
resizeObserverDelegate_->runResizeObservations(runtime);
} catch (jsi::JSError& error) {
handleTaskError(runtime, error);
onTaskError_(runtime, error);
} catch (std::exception& ex) {
jsi::JSError error(
runtime, std::string("Non-JS exception: ") + ex.what());
handleTaskError(runtime, error);
onTaskError_(runtime, error);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,8 @@ TEST_P(RuntimeSchedulerTest, errorInResizeObservationsDoesNotStopUpdate) {
return;
}

setUpFeatureFlags(/*enableRuntimeSchedulerQueueClearingOnError=*/true);

StubResizeObserverDelegate resizeObserverDelegate;
resizeObserverDelegate.onRunResizeObservations = [](jsi::Runtime& runtime) {
throw jsi::JSError(runtime, "Test error");
Expand All @@ -1848,6 +1850,9 @@ TEST_P(RuntimeSchedulerTest, errorInResizeObservationsDoesNotStopUpdate) {

// Delivering observations to JS synchronously happens outside the error
// boundary of the task, so the step handles the error itself and carries on.
// In particular the error must not be routed through `handleTaskError`:
// that clears the pending rendering updates this same step is about to
// drain, and `didRunRenderingUpdate` below would be false.
EXPECT_EQ(stubErrorUtils_->getReportFatalCallCount(), 1);
EXPECT_EQ(resizeObserverDelegate.callCount, 1);
EXPECT_EQ(intersectionObserverDelegate.callCount, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,15 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
enableRuntimeSchedulerQueueClearingOnError: {
defaultValue: false,
defaultValue: true,
metadata: {
dateAdded: '2026-05-19',
description:
'When enabled, RuntimeScheduler_Modern clears pending tasks and rendering updates before handling an error.',
expectedReleaseValue: true,
purpose: 'experimentation',
},
ossReleaseStage: 'experimental',
ossReleaseStage: 'none',
},
enableSchedulerDelegateInvalidation: {
defaultValue: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<fbab08ee89a2969b45034a45b6425581>>
* @generated SignedSource<<2adcae106ae1e758061a91ee20f902fd>>
* @flow strict
* @noformat
*/
Expand Down Expand Up @@ -387,7 +387,7 @@ export const enableResizeObserverByDefault: Getter<boolean> = createNativeFlagGe
/**
* When enabled, RuntimeScheduler_Modern clears pending tasks and rendering updates before handling an error.
*/
export const enableRuntimeSchedulerQueueClearingOnError: Getter<boolean> = createNativeFlagGetter('enableRuntimeSchedulerQueueClearingOnError', false);
export const enableRuntimeSchedulerQueueClearingOnError: Getter<boolean> = createNativeFlagGetter('enableRuntimeSchedulerQueueClearingOnError', true);
/**
* Gates a defensive guard around Scheduler::uiManagerDidDispatchCommand and uiManagerDidFinishTransaction that prevents queued rendering-update lambdas from dereferencing the SchedulerDelegate after it has been destroyed (use-after-free).
*/
Expand Down
Loading