doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.29k stars 1.01k forks source link

[bug][android][newarch] useEffects no longer updates once app is minimized #2392

Open lovegaoshi opened 14 hours ago

lovegaoshi commented 14 hours ago

Describe the Bug useEffects no longer updates once app is minimized. I've confirmed this is directly related to RNTP and new arch interaction, as I tested on my newArchExample repo with RN 0.75.3 + the 2 headlessJs patches, and RNTP + the 2 new arch patches, and can reproduce the issue.

In the repo provided, look at the counter at the very top, it increases by 1 every second. by minimizing and re-opening the app, it wont count anymore. If headlessJs is not involved I believe the counter works.

Steps To Reproduce ook at the counter at the very top, it increases by 1 every second. by minimizing and re-opening the app, it wont count anymore

Code To Reproduce https://github.com/lovegaoshi/RNTPExampleNewArch/tree/eb1707c04b85f1095355f998d6de46ead72a5d72

Replicable on Example App? yes

Environment Info: specifically on android

How I can Help n/A

lovegaoshi commented 13 hours ago

ive pinned down to mActiveTasks.add(taskId); in haedlessJsTaskContext.java that affects the hook behaviors

clearFrameCallback in JavaTimerManager.py. seems like

      mReactChoreographer.removeFrameCallback(
          ReactChoreographer.CallbackType.TIMERS_EVENTS, mTimerFrameCallback);
      mFrameCallbackPosted = false;

needs to be always called, instaed of only when there is no active headlessTask.

since this function is called onHostPause, which is minimizing the app, the behavior is expecetd - tho i dont have a clue what any of this do

lovegaoshi commented 11 hours ago

proposed patch? https://github.com/lovegaoshi/azusa-player-mobile/commit/57025b915a9558b97574ebb45e5789b966d3993d

lovegaoshi commented 10 hours ago

headlessJsTaskService could not complete a fetch request when app is in background

lovegaoshi commented 8 hours ago

tracked by https://github.com/facebook/react-native/issues/47436