NativeScript / android

NativeScript for Android using v8
https://docs.nativescript.org/guide/android-marshalling
Apache License 2.0
519 stars 135 forks source link

requestAnimationFrame broken on sdk > 23 (removeFrameCallback breaks postFrameCallback) #1737

Closed delaneyb closed 1 year ago

delaneyb commented 1 year ago

Environment Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

Describe the bug Passing a callback to removeFrameCallback prevents it from being invoked next time it is passed to postFrameCallback. Due to this, requestAnimationFrame can be used in a series only once. After we stop calling requestAnimationFrame, removeFrameCallback is called internally by the FPSCallback instance used by requestAnimationFrame. If we then call requestAnimationFrame again later (can be with a completely different callback), our callback only gets invoked once immediately but then not again after calling requestAnimationFrame from inside our callback.

To Reproduce Sample project https://stackblitz.com/edit/nativescript-stackblitz-templates-9ktwdn?file=app/components/Home.vue

Expected behavior Button should animate each time it is pressed

Additional context I made a work around for this issue by constructing and starting a new FPSCallback instance directly for my animations (so they have a different unique impl passed to post/removeFrameCallback as opposed to the single global one shared by the instance of FPSCallback used by requestAnimationFrame animation-frame/index.js). However, since doing this my app now seems to consistently crash with no output anywhere from immediately to a minute or two after constructing and starting the fpsCallback instance. With adb logcat --pid=$(adb shell pidof -s com.myappname.app) I was able to get a little crash info that was filtered out by the CLI but it still does not seem helpful:

11-05 18:38:09.942 23019 23019 E v8      : #
11-05 18:38:09.942 23019 23019 E v8      : # Fatal error in , line 0
11-05 18:38:09.942 23019 23019 E v8      : #
11-05 18:38:09.942 23019 23019 E v8      : ignored
11-05 18:38:09.942 23019 23019 E v8      : #
11-05 18:38:09.942 23019 23019 E v8      : #
11-05 18:38:09.942 23019 23019 E v8      : #
11-05 18:38:09.942 23019 23019 E v8      : #FailureMessage Object: 0x7fefb74a70
11-05 18:38:09.943 23019 23019 I v8      :
--------- beginning of crash
11-05 18:38:09.943 23019 23019 F libc    : Fatal signal 5 (SIGTRAP), code 1 (TRAP_BRKPT), fault addr 0x6fa46a2560 in tid 23019 (m.myappname.app), pid 23019 (m.myappname.app)
triniwiz commented 1 year ago

Can you try the alpha version , thanks

delaneyb commented 1 year ago

Can you try the alpha version , thanks

Repro seems to be fixed in alpha, thanks 👍