diff --git a/packages/react-native/ReactCommon/react/renderer/core/EventBeat.cpp b/packages/react-native/ReactCommon/react/renderer/core/EventBeat.cpp index 9a9fd5266d798a..e00ad5fb785482 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/EventBeat.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/EventBeat.cpp @@ -7,6 +7,7 @@ #include "EventBeat.h" +#include #include #include @@ -18,6 +19,9 @@ EventBeat::EventBeat( : ownerBox_(std::move(ownerBox)), runtimeScheduler_(runtimeScheduler) {} void EventBeat::request() const { + react_native_assert( + beatCallback_ && + "Unexpected state: EventBeat::setBeatCallback was not called before EventBeat::request."); isRequested_ = true; } diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp index f5f37c91792def..432450ae43fae9 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -54,17 +54,18 @@ Scheduler::Scheduler( auto weakRuntimeScheduler = contextContainer_->find>( "RuntimeScheduler"); - auto runtimeScheduler = weakRuntimeScheduler.has_value() - ? weakRuntimeScheduler.value().lock() - : nullptr; + react_native_assert( + weakRuntimeScheduler.has_value() && + "Unexpected state: RuntimeScheduler was not provided."); + + auto runtimeScheduler = weakRuntimeScheduler.value().lock(); - if (runtimeScheduler && ReactNativeFeatureFlags::enableUIConsistency()) { + if (ReactNativeFeatureFlags::enableUIConsistency()) { runtimeScheduler->setShadowTreeRevisionConsistencyManager( uiManager->getShadowTreeRevisionConsistencyManager()); } - if (runtimeScheduler && - ReactNativeFeatureFlags::enableReportEventPaintTime()) { + if (ReactNativeFeatureFlags::enableReportEventPaintTime()) { runtimeScheduler->setEventTimingDelegate(eventPerformanceLogger_.get()); }