mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Resume frame callback on host resume (#47264)
Summary: When the app goes into background the frame callback is ignored by setting the `mShouldStop` flag to `true` https://github.com/facebook/react-native/blob/3111473d571a8315d11753f8c6acddd2ba301f8f/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.java#L174 However this flag is never reset even after the app is back on foreground. This made the `AndroidEventBeat` not ticking in as much as expected causing events not being dispatched in time. In our case the `onLayout` was not being dispatched unless we tap on screen invoking a manual tick. ## Changelog: [ANDROID] [FIXED] - Fix Frame Callback not being called after Host Resume Pull Request resolved: https://github.com/facebook/react-native/pull/47264 Test Plan: 1. Add log line `__android_log_print(ANDROID_LOG_DEBUG, "s77rt", "AndroidEventBeat::tick");` in `packages/react-native/ReactAndroid/src/main/jni/react/fabric/AndroidEventBeat.cpp` (tick method) 2. Open RN-Tester 3. Verify `AndroidEventBeat::tick` is logged for every frame 4. Put app into background 5. Verify no `AndroidEventBeat::tick` is logged 6. Open app again 7. Verify `AndroidEventBeat::tick` is logged for every frame | Before | After | |:------:|:-----:| | <video src="https://github.com/user-attachments/assets/9667ed49-3a56-4c30-992f-9e6426f5d08e" /> | <video src="https://github.com/user-attachments/assets/548ae199-d9a2-497c-bba7-b89c4d684836" /> | | <video src="https://github.com/user-attachments/assets/e14851aa-0609-4b36-bf1e-dfd5d2ee8512" /> | <video src="https://github.com/user-attachments/assets/db5a9fe6-dfc1-4b3c-92b0-359b4b68ac5c" /> | Reviewed By: NickGerleman Differential Revision: D65136338 Pulled By: javache fbshipit-source-id: 0a101be2a7588cbbb5a55ee4d420082f85566c1b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e51c32d7cf
commit
e8f8ee3c0f
+7
@@ -143,6 +143,9 @@ public class FabricEventDispatcher implements EventDispatcher, LifecycleEventLis
|
||||
@Override
|
||||
public void onHostResume() {
|
||||
scheduleDispatchOfBatchedEvents();
|
||||
if (!ReactNativeFeatureFlags.useOptimizedEventBatchingOnAndroid()) {
|
||||
mCurrentFrameCallback.resume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,6 +219,10 @@ public class FabricEventDispatcher implements EventDispatcher, LifecycleEventLis
|
||||
mShouldStop = true;
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
mShouldStop = false;
|
||||
}
|
||||
|
||||
public void maybeDispatchBatchedEvents() {
|
||||
if (!mIsDispatchScheduled) {
|
||||
mIsDispatchScheduled = true;
|
||||
|
||||
Reference in New Issue
Block a user