osmdroid: Zoom Button Crash in 6.1.0
Issue Type
[X] Bug
Description and/or steps/code to reproduce the problem
Plugging 6.1.0 into gradle to replace 6.0.3 in my App, all things so far seem fine. All but the (standard) zoom buttons: These bottons relyably crash 100% of the time after app start. With plenty of stack trace which all seem repeations of this (one click creates hundreds and so far I only checked manually):
2019-03-25 09:26:07.704 ? E/AndroidRuntime: at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
2019-03-25 09:26:07.704 ? E/AndroidRuntime: at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.end(ValueAnimator.java:1133)
at org.osmdroid.views.MapController.animateTo(MapController.java:167)
at org.osmdroid.views.MapController.animateTo(MapController.java:137)
at org.osmdroid.views.MapController.animateTo(MapController.java:183)
at org.osmdroid.views.MapController.animateTo(MapController.java:129)
at org.osmdroid.views.MapView.setZoomLevel(MapView.java:492)
at org.osmdroid.views.MapController$MapAnimatorListener.onAnimationUpdate(MapController.java:520)
at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1547)
at android.animation.ValueAnimator.animateBasedOnTime(ValueAnimator.java:1339)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1471)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1170)
at android.view.Choreographer.doCallbacks(Choreographer.java:984)
at android.view.Choreographer.doFrame(Choreographer.java:806)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1158)
at android.os.Handler.handleCallback(Handler.java:873)
2019-03-25 09:26:07.704 ? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6863)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Once the user has done some manual (gesture or in my App location bookmarks) zooming or location change, this does not happen any more. But when the user hits zoom directly after start it crashes relyably.
The stack traces seem to depend on Android version, on Android 4.2.2 I get the following:
03-25 09:42:27.976 de.spieleck.app.badgers.debug E/AndroidRuntime: FATAL EXCEPTION: main java.lang.StackOverflowError
(which matches to the amount of output on Android 9 where log is just to fast to keep the start of problems in Android Studio memory).
Environment
My Badge®s App, Android 4.2.2, 9 checked here
If it’s a bug, version(s) of android this affects:
A9, 4.2.2
Version of osmdroid the issue relates to:
6.1.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 39 (14 by maintainers)
Commits related to this issue
- bug #1299: Zoom Button Crash in 6.1.0 fix StackOverflow, because when zooming in with zoom buttons, osm tries to keep the map centered to the current user location. See: org.osmdroid.views.overlay.myl... — committed to shorti1996/osmdroid by shorti1996 5 years ago
- bug #1299: Zoom Button Crash in 6.1.0 fix StackOverflow, because when zooming in with zoom buttons, osm tries to keep the map centered to the current user location. See: org.osmdroid.views.overlay.myl... — committed to shorti1996/osmdroid by shorti1996 5 years ago
- bug/#1299 - partial rollback of the custom zoom buttons We temporarily roll back to the standard Android zoom buttons, as the default zoom controller. If a developer wants to switch to the new custom... — committed to osmdroid/osmdroid by monsieurtanuki 5 years ago
- bug/#1299 - partial rollback of the custom zoom buttons We temporarily roll back to the standard Android zoom buttons, as the default zoom controller. If a developer wants to switch to the new custom... — committed to osmdroid/osmdroid by monsieurtanuki 5 years ago
- Bug/#1299 2 - partial rollback of the custom zoom buttons (#1315) * bug/#1299 - partial rollback of the custom zoom buttons We temporarily roll back to the standard Android zoom buttons, as the de... — committed to osmdroid/osmdroid by monsieurtanuki 5 years ago
- bug #1299: Zoom Button Crash in 6.1.0 (#1307) fix StackOverflow, because when zooming in with zoom buttons, osm tries to keep the map centered to the current user location. See: org.osmdroid.views.... — committed to osmdroid/osmdroid by shorti1996 5 years ago
if we are all in concur on this, i can merge and get a new version rolled out today or tomorrow
Success today!
The issue is related to any app having a Snappable overlay (an
OwnLocationOverlay):This code in
setZoomLevelhttps://github.com/osmdroid/osmdroid/blob/8bcb806f8d763e4a1e36813c8ac6b7e763cb2b6f/osmdroid-android/src/main/java/org/osmdroid/views/MapView.java#L500 getstruefromonSnapItemhttps://github.com/osmdroid/osmdroid/blob/832e0813d394e83106c5cdc3beb642d38d5dbade/osmdroid-android/src/main/java/org/osmdroid/views/overlay/DefaultOverlayManager.java#L270 and continuously callsanimateToleading to SO:and onSnapItem:
I could repro stack overflow by hardcoding
return true;inonSnapToItem; patch this below.and zoom out to stack overflow at will in Osmdroid-android test app!I created this patch to get keyboard working in Android Emulator:
With the change above, I tried to zoom to 12 (pressing BACKSLASH, which is what I start at in my app) in Osmdroid tests (ExtraSamplesActivity), and then out (MINUS) which I understand zooms out to 11. The zoomAnimatorListener are the same in ExtraSamplesActivity and my app; in ExtraSamplesActivity it seems to work fine… In my app I hit zoom 11 and keep hitting 11 in an endless loop leading to stack overflow (
valueAnimator.getAnimatedValue()keeps on returning the same value of 1.0f):On both sides I am at b6ea341a9bc2658011f827f57edeaf3baea51fc8
I use avd (AS 3.4 on Ubuntu/Intel). I find android keyboard hooks v useful. Maybe you just need to send few zoomIn events:
Ok, I got it. You should PERFECTLY center the map to your location (so for example using enableFollowLocation and wait for it to center). Then the app crashes because there is an infinite recursion.
It’s caused by the fact that each time the zoom updates, osm tries to “snap” to the user location using
org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay#onSnapToItem.I can revert https://github.com/osmdroid/osmdroid/pull/1237 for now and try to fix both issues later.
I have exactly the same problem (both my working app and a simple test app with MapView and LocationOverlay). Tested on Android 5 (AVD) and Android 9 (Samsung S9) It only happens when zoom in / out just after app start. I use the buttons that appear after tapping The beginning of my error log is:
…and repeated several times
My code in ‘empty’ MainActivity: