mapbox / mapbox-maps-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
https://www.mapbox.com/mobile-maps-sdk
Other
475 stars 132 forks source link

IllegalArgumentException kotlin.math.MathKt__MathJVMKt in roundToInt #2074

Open pizzacoffeecode opened 1 year ago

pizzacoffeecode commented 1 year ago

Environment

Observed behavior and steps to reproduce

Unknown

Expected behavior

App not to crash

Notes / preliminary analysis

There are no references to custom code in error logs, all looks related to mapbox.

Additional links and references

`kotlin.math.MathKt__MathJVMKt in roundToInt at line 619

com.mapbox.maps.plugin.viewport.transition.TransitionUtilsKt in roundTo at line 46

com.mapbox.maps.plugin.viewport.transition.TransitionUtilsKt in normalizeBearing at line 37

com.mapbox.maps.plugin.viewport.transition.MapboxViewportTransitionFactory in transitionFromLowZoomToHighZoom at line 72

com.mapbox.maps.plugin.viewport.transition.DefaultViewportTransitionImpl in createAnimatorSet at line 137

com.mapbox.maps.plugin.viewport.transition.DefaultViewportTransitionImpl in run$lambda-3 at line 68

com.mapbox.maps.plugin.viewport.transition.DefaultViewportTransitionImpl in $r8$lambda$Dm5KN4W8ZFs-jPnk6TvM6D2XbLA

com.mapbox.maps.plugin.viewport.transition.DefaultViewportTransitionImpl$$ExternalSyntheticLambda1 in onNewData at line 15

com.mapbox.maps.plugin.viewport.state.FollowPuckViewportStateImpl in notifyViewportStateDataObserver at line 81

com.mapbox.maps.plugin.viewport.state.FollowPuckViewportStateImpl in notifyLatestViewportData at line 69

com.mapbox.maps.plugin.viewport.state.FollowPuckViewportStateImpl in indicatorPositionChangedListener$lambda-0 at line 51

com.mapbox.maps.plugin.viewport.state.FollowPuckViewportStateImpl in $r8$lambda$1FFQMeE76PqUckIDkzhBjeBUQTc

com.mapbox.maps.plugin.viewport.state.FollowPuckViewportStateImpl$$ExternalSyntheticLambda2 in onIndicatorPositionChanged at line 2

com.mapbox.maps.plugin.locationcomponent.LocationComponentPluginImpl in indicatorPositionChangedListener$lambda-1 at line 81

com.mapbox.maps.plugin.locationcomponent.LocationComponentPluginImpl in $r8$lambda$tH84PKxP_CGg6Eh9PozddvGFbNI

com.mapbox.maps.plugin.locationcomponent.LocationComponentPluginImpl$$ExternalSyntheticLambda3 in onIndicatorPositionChanged at line 2

com.mapbox.maps.plugin.locationcomponent.animators.PuckPositionAnimator in updateLayer at line 10

com.mapbox.maps.plugin.locationcomponent.animators.PuckPositionAnimator in updateLayer at line 6

com.mapbox.maps.plugin.locationcomponent.animators.PuckAnimator$1$1 in invoke at line 36

com.mapbox.maps.plugin.locationcomponent.animators.PuckAnimator$1$1 in invoke at line 33

com.mapbox.maps.threading.AnimationThreadController in postOnMainThread at line 67

com.mapbox.maps.plugin.locationcomponent.animators.PuckAnimator in init$lambda-0 at line 33

com.mapbox.maps.plugin.locationcomponent.animators.PuckAnimator in $r8$lambda$DKuRutUBCyf6yKd5UEMf-U8meWw

com.mapbox.maps.plugin.locationcomponent.animators.PuckAnimator$$ExternalSyntheticLambda0 in onAnimationUpdate at line 2

android.animation.ValueAnimator in animateValue at line 1566

android.animation.ValueAnimator in animateBasedOnTime at line 1357

android.animation.ValueAnimator in doAnimationFrame at line 1489

android.animation.AnimationHandler in doAnimationFrame at line 146

android.animation.AnimationHandler in access$100 at line 37

android.animation.AnimationHandler$1 in doFrame at line 54

android.view.Choreographer$CallbackRecord in run at line 970

android.view.Choreographer in doCallbacks at line 796

android.view.Choreographer in doFrame at line 727

android.view.Choreographer$FrameDisplayEventReceiver in run at line 957

android.os.Handler in handleCallback at line 938

android.os.Handler in dispatchMessage at line 99

android.os.Looper in loop at line 223

android.app.ActivityThread in main at line 7680

java.lang.reflect.Method in invoke

com.android.internal.os.RuntimeInit$MethodAndArgsCaller in run at line 592

com.android.internal.os.ZygoteInit in main at line 947`

yunikkk commented 1 year ago

@pizzacoffeecode hey, any other information how this crash was triggered? From the codebase it looks all the vars are guarded against null, MapboxViewportTransitionFactory, Utils

SamYStudiO commented 11 months ago

Hi, I go it in my firebase logs as well. It's not a null problem but a NaN problem. java.lang.IllegalArgumentException: Cannot round NaN value. i guess from MapboxViewportTransitionFactory currentMapCameraState.bearing is NaN at that time.

SamYStudiO commented 6 months ago

@yunikkk This is still an issue with 11.4

Fatal Exception: java.lang.IllegalArgumentException: Cannot round NaN value.
       at kotlin.math.MathKt__MathJVMKt.roundToInt(MathJVM.kt:619)
       at com.mapbox.maps.plugin.viewport.transition.TransitionUtilsKt.roundTo(TransitionUtils.kt:46)
       at com.mapbox.maps.plugin.viewport.transition.TransitionUtilsKt.normalizeBearing(TransitionUtils.kt:37)
       at com.mapbox.maps.plugin.viewport.transition.MapboxViewportTransitionFactory.transitionFromHighZoomToLowZoom(MapboxViewportTransitionFactory.kt:129)
       at com.mapbox.maps.plugin.viewport.transition.DefaultViewportTransitionImpl.createAnimatorSet(DefaultViewportTransitionImpl.kt:142)
       at com.mapbox.maps.plugin.viewport.transition.DefaultViewportTransitionImpl.run$lambda$3(DefaultViewportTransitionImpl.kt:71)
       at com.mapbox.maps.plugin.viewport.state.FollowPuckViewportStateImpl.notifyViewportStateDataObserver(FollowPuckViewportStateImpl.kt:94)
       at com.mapbox.maps.plugin.viewport.state.FollowPuckViewportStateImpl.observeDataSource(FollowPuckViewportStateImpl.kt:152)
       at com.mapbox.maps.plugin.viewport.transition.DefaultViewportTransitionImpl.run(DefaultViewportTransitionImpl.kt:65)
       at com.mapbox.maps.plugin.viewport.ViewportPluginImpl.transitionTo(ViewportPluginImpl.kt:152)
       at com.mapbox.maps.plugin.viewport.ViewportPlugin$DefaultImpls.transitionTo$default(ViewportPlugin.kt:55)
       at com.openrunner.android.ui.base.fragment.BaseLocationMapFragment.updateFollowPuckOptions(BaseLocationMapFragment.kt:250)
       at com.openrunner.android.ui.base.fragment.BaseLocationMapFragment.access$toggleLocationType(BaseLocationMapFragment.kt:37)
       at com.openrunner.android.ui.base.fragment.BaseLocationMapFragment.access$updateFollowPuckOptions(BaseLocationMapFragment.kt:37)
       at com.openrunner.android.ui.base.fragment.BaseLocationMapFragment$onViewCreated$5.invoke(BaseLocationMapFragment.kt:138)
       at com.openrunner.android.ui.base.fragment.BaseLocationMapFragment$onViewCreated$5.invoke(BaseLocationMapFragment.kt:128)
       at com.openrunner.android.ui.base.fragment.BaseLocationMapFragment$sam$androidx_lifecycle_Observer$0.onChanged(BaseLocationMapFragment.kt:2)
       at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
       at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
       at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
       at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
       at androidx.lifecycle.SavedStateHandle$SavingStateLiveData.setValue(SavedStateHandle.kt:391)
       at androidx.lifecycle.SavedStateHandle.set(SavedStateHandle.kt:298)
       at com.openrunner.android.ui.base.fragment.BaseLocationMapViewModel.setMyLocationType(BaseLocationMapViewModel.kt:58)
       at com.openrunner.android.ui.main.map.MapFragment$onViewCreated$26.invoke(MapFragment.kt:487)
       at com.openrunner.android.ui.main.map.MapFragment$onViewCreated$26.invoke(MapFragment.kt:486)
       at com.openrunner.android.ui.main.map.MapFragment$sam$androidx_lifecycle_Observer$0.onChanged(MapFragment.kt:2)
       at com.openrunner.android.ui.common.viewmodel.SingleLiveEvent$ObserverWrapper.onChanged(SingleLiveEvent.kt:67)
       at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
       at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
       at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
       at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
       at com.openrunner.android.ui.common.viewmodel.SingleLiveEvent.setValue(SingleLiveEvent.kt:53)
       at com.openrunner.android.ui.common.viewmodel.SingleLiveEventKt$toSingleLiveEvent$1$1.invoke(SingleLiveEvent.kt:83)
       at com.openrunner.android.ui.common.viewmodel.SingleLiveEventKt$toSingleLiveEvent$1$1.invoke(SingleLiveEvent.kt:82)
       at com.openrunner.android.ui.common.viewmodel.SingleLiveEventKt$sam$i$androidx_lifecycle_Observer$0.onChanged(SingleLiveEvent.kt:3)
       at androidx.lifecycle.MediatorLiveData$Source.onChanged(MediatorLiveData.java:171)
       at androidx.lifecycle.LiveData.considerNotify(LiveData.java:133)
       at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:151)
       at androidx.lifecycle.LiveData.setValue(LiveData.java:309)
       at androidx.lifecycle.LiveData$1.run(LiveData.java:93)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:223)
       at android.app.ActivityThread.main(ActivityThread.java:7680)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:423)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
ignaciotcrespo commented 4 months ago

hi, I still have this issue in my app, reported in firebase, it is causing some crashes. Any news about it?

At least for my app, it happens only in device OnePlus8Pro with Android 11.