Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android 9] Crash on opening a Modal with KeyboardProvider around the app #714

Closed
wcastand opened this issue Dec 2, 2024 · 13 comments · Fixed by #718
Closed

[Android 9] Crash on opening a Modal with KeyboardProvider around the app #714

wcastand opened this issue Dec 2, 2024 · 13 comments · Fixed by #718
Assignees
Labels
🤖 android Android specific 🎯 crash Library triggers a crash of the app 🌎 modal Anything that involves Modal usage repro provided Issue contains reproduction repository/code

Comments

@wcastand
Copy link

wcastand commented Dec 2, 2024

Describe the bug
Only happening to me on <= Android 9 so far, when i open a Modal from react-native, the app crashes. error being java.lang.RuntimeException: folly::toJson: JSON object value was an INF when serializing value at "progress"
seems to be related to animated values hitting the INF value somehow. the crash disapear when i remove <KeyboardController/> from my layout.

I'm on an expo dev client app on SDK 52

Couldn't manage to a minimal reproduce so far but will keep trying, just wanted to make the issue in case the error makes more sense to you than to me x)

Expected behavior
No crash

Smartphone (please complete the following information):

  • Desktop OS: MAc 15.1.1
  • Device: android Samsung Galaxy S8
  • OS: 9
  • RN version: 0.76.3
  • RN architecture: old
  • JS engine: hermes
  • Library version: 1.14.5

Additional context

here the error log:

ERROR  Your app just crashed. See the error below.
java.lang.RuntimeException: folly::toJson: JSON object value was an INF when serializing value at "progress"
  com.facebook.react.bridge.NativeMap.toString(Native Method)
  com.swmansion.reanimated.nativeProxy.EventHandler.receiveEvent(Native Method)
  com.swmansion.reanimated.nativeProxy.EventHandler.receiveEvent(EventHandler.java:25)
  com.facebook.react.uimanager.events.Event.dispatch(Event.java:173)
  com.swmansion.reanimated.NodesManager.handleEvent(NodesManager.java:350)
  com.swmansion.reanimated.NodesManager.onEventDispatch(NodesManager.java:336)
  com.facebook.react.uimanager.events.EventDispatcherImpl.dispatchEvent(EventDispatcherImpl.java:119)
  com.reactnativekeyboardcontroller.extensions.ThemedReactContextKt.dispatchEvent(ThemedReactContext.kt:23)
  com.reactnativekeyboardcontroller.listeners.KeyboardAnimationCallback.onProgress(KeyboardAnimationCallback.kt:267)
  androidx.core.view.WindowInsetsAnimationCompat$Impl21.dispatchOnProgress(WindowInsetsAnimationCompat.java:922)
  androidx.core.view.WindowInsetsAnimationCompat$Impl21$Impl21OnApplyWindowInsetsListener$1.onAnimationUpdate(WindowInsetsAnimationCompat.java:832)
  android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
  android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:674)
  android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:637)
  android.animation.ValueAnimator.start(ValueAnimator.java:1069)
  android.animation.ValueAnimator.start(ValueAnimator.java:1088)
  androidx.core.view.WindowInsetsAnimationCompat$Impl21$Impl21OnApplyWindowInsetsListener$3.run(WindowInsetsAnimationCompat.java:852)
  androidx.core.view.OneShotPreDrawListener.onPreDraw(OneShotPreDrawListener.java:71)
  android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:991)
  android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3016)
  android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1885)
  android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8508)
  android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
  android.view.Choreographer.doCallbacks(Choreographer.java:761)
  android.view.Choreographer.doFrame(Choreographer.java:696)
  android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
  android.os.Handler.handleCallback(Handler.java:873)
  android.os.Handler.dispatchMessage(Handler.java:99)
  android.os.Looper.loop(Looper.java:214)
  android.app.ActivityThread.main(ActivityThread.java:7050)
  java.lang.reflect.Method.invoke(Native Method)
  com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
@kirillzyusko kirillzyusko added 🤖 android Android specific 🎯 crash Library triggers a crash of the app labels Dec 2, 2024
@kirillzyusko
Copy link
Owner

@wcastand interesting! I'm constantly running e2e tests that include an integration with Modal and so far I don't receive any crashes.

The problem is that progress with Inf value can not be serialized as number and passed to JS. The only thing is that i don't understand how progress can be calculated as Inf - if you can provide a minimal reproduction example that would help a lot and speed up the development of the fix!

@wcastand
Copy link
Author

wcastand commented Dec 2, 2024

yeah i tried to make a repro knowing it would help a lot but must be a combination of weird things in our repo + it's on old android phone and it's so slow to test xDDD

i tried multiple things already but no luck so far :/

@kirillzyusko
Copy link
Owner

@wcastand yeah, I have Android 9 real device so I understand the pain 😅

Probably you are right - it's a combination of things. So really keen to know what exactly makes progress to be infinity 🤔

@wcastand
Copy link
Author

wcastand commented Dec 2, 2024

it was a hard battle but after a few hours, i got it ahah

https://github.com/wcastand/bug-modal-android

hopefully it crashes for you too now 😅

@kirillzyusko kirillzyusko added repro provided Issue contains reproduction repository/code 🌎 modal Anything that involves Modal usage labels Dec 3, 2024
@kirillzyusko
Copy link
Owner

@wcastand can you check if #718 fixes the problem? 👀

@wcastand
Copy link
Author

wcastand commented Dec 3, 2024

@kirillzyusko copied the code of the PR in my repo and no more crashes on my samsung !

@kirillzyusko
Copy link
Owner

@wcastand awesome! Then you can temporarily patch the dependency via patch-package in your project, and I'll merge the fix and publish it with the next release!

Don't have any ETA at the moment (I though I could publish it in first weeks of December, but let's see how it goes 👀), but I hope I can publish it this month 🙂

@wcastand
Copy link
Author

wcastand commented Jan 3, 2025

looks like i get the crash on a pixel 9 with android 15 with the same error msg and same screen :/ @kirillzyusko

@kirillzyusko
Copy link
Owner

@wcastand which version of the library do you use? Basically I think it's impossible to get the same crash, because we added a check, that will set progress to 0 if it's infinity. Can you share an error again? Maybe it's the same error but comes from a different place? 🤔

@wcastand
Copy link
Author

wcastand commented Jan 6, 2025

i tried to reproduce locally on the same device as the user and same android version but coulnd't do it so far. the reason i posted a comment is because it's the same error msg, in the same place in the app, with the same behavior etc.
it's like identical but i agree we should have covered this edge case.

I was wondering since it's on android 15, the newest could it be that the lib doesn't check for android 15 or they changed their API again or something like that, that would branch into a place where we don't do the check?

@kirillzyusko
Copy link
Owner

@wcastand ah, I understand what do you mean. Well, the problem that you described and prepared a reproduction for was really easily reproducible - and I fixed it in #718

However people later on discovered that the same issue happens on newest Android devices too (such as Android 14/15) - but the problem was the fact that people were able to see exceptions in Sentry/Crashlytic/etc., but weren't able to reproduce it on their own or in reproduction examples.

I assume it can be kind of a race condition that may be hard to catch at the moment and to fix this edge case I cane up with another solution in #740 (it's more like a workaround, but I think it's better to show non existing animation rather than crash the app).

And I believe I included latest fix in 1.15.1. So may I ask you which version of the library did you use where you've seen the problem? If it was < 1.15.1 may I ask you to update to latest version (1.15.2) and check if the problem is reproducible again?

@wcastand
Copy link
Author

wcastand commented Jan 7, 2025

i'm on 1.15.2 on dev, but production is on 1.14.5

could be explaining why i couldn't reproduce locally ! :)

Thanks for the time and explanation i will push the update as soon as possible in production and hopefully it will fix the crash for us too. :) for now i think we can assume it's good to go :)

@kirillzyusko
Copy link
Owner

Awesome @wcastand ! 🔥

In case if you find a way to reproduce the problem - don't hesitate to open a new issue or post an update here 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Android specific 🎯 crash Library triggers a crash of the app 🌎 modal Anything that involves Modal usage repro provided Issue contains reproduction repository/code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants