Environment
- Android OS version: Android Automotive OS (Android 13+)
- Devices affected: Infotainment systems with dual-pane displays. Likely affects any Android Automotive or multi-window setup where the app runs in a secondary pane with a non-zero display offset.
- Maps SDK Version: 11.16.2 (Mapbox Maps SDK for Android)
Observed behavior and steps to reproduce
- Run an app containing a
MapboxMap (Compose) or MapView in a dual-pane / split-screen configuration where the app is positioned in the right/secondary pane
- Attempt to drag (pan) the map — the camera does not move
- Attempt to pinch-to-zoom — the gesture either doesn't respond or zooms to the wrong focal point
- Tap on the map — this works correctly
- Fast fling (drag and lift quickly) — may partially work, moving the camera via the fling animation
The issue does not occur when the app runs in the left/primary pane or in full-screen mode.
Diagnostic findings
We instrumented touch events on the MapView and found:
|
Left pane (working) |
Right pane (broken) |
getX() / getY() |
Correct (view-relative) |
Correct (view-relative) |
getRawX() / getRawY() |
Same as getX/Y |
Offset by pane position (~860–2880px in X) |
getLocationOnScreen() |
(0, 0) |
(0, 0) — incorrect, should reflect pane offset |
getLocationInWindow() |
(0, 0) |
(0, 0) |
The SDK's internal gesture detectors (e.g. MoveGestureDetector) appear to use getRawX()/getRawY() for focal point calculations. Since getLocationOnScreen() incorrectly reports (0, 0) on the right pane, the SDK cannot compensate for the display offset, resulting in a focal point that is off by the pane's X offset (e.g. ~2880px on a wide display).
Expected behavior
Drag, pinch-to-zoom, and all other map gestures should work correctly regardless of the app's position on the display — including when running in a secondary pane in a dual-pane or multi-window configuration.
Notes / preliminary analysis
The root cause appears to be in the gesture handling pipeline within the SDK. Specifically:
- The gesture detectors use
MotionEvent.getRawX()/getRawY() (display-absolute coordinates) for focal point and movement delta calculations
- On dual-pane automotive displays, the
MapView reports getLocationOnScreen() = (0, 0) even when it has a significant display offset, so the SDK cannot correct for the difference between raw and local coordinates
- This is similar to the issue fixed in PR #1575 (
MapSurface#surfaceChanged not updating dimensions for plugins) and related to issue #2131 (coordinate projection issues)
Our workaround: We intercept touch events via setOnTouchListener and create corrected MotionEvent copies (using MotionEvent.obtain() with PointerCoords from getPointerCoords()) where getRawX() == getX(), then dispatch the corrected event to MapView.onTouchEvent(). This resolves the issue for all gesture types.
A proper SDK fix would likely involve the gesture detectors using view-relative coordinates (getX()/getY()) instead of getRawX()/getRawY(), or correctly accounting for the view's screen position when computing focal points.
Additional links and references
Environment
Observed behavior and steps to reproduce
MapboxMap(Compose) orMapViewin a dual-pane / split-screen configuration where the app is positioned in the right/secondary paneThe issue does not occur when the app runs in the left/primary pane or in full-screen mode.
Diagnostic findings
We instrumented touch events on the
MapViewand found:getX()/getY()getRawX()/getRawY()getX/YgetLocationOnScreen()(0, 0)(0, 0)— incorrect, should reflect pane offsetgetLocationInWindow()(0, 0)(0, 0)The SDK's internal gesture detectors (e.g.
MoveGestureDetector) appear to usegetRawX()/getRawY()for focal point calculations. SincegetLocationOnScreen()incorrectly reports(0, 0)on the right pane, the SDK cannot compensate for the display offset, resulting in a focal point that is off by the pane's X offset (e.g. ~2880px on a wide display).Expected behavior
Drag, pinch-to-zoom, and all other map gestures should work correctly regardless of the app's position on the display — including when running in a secondary pane in a dual-pane or multi-window configuration.
Notes / preliminary analysis
The root cause appears to be in the gesture handling pipeline within the SDK. Specifically:
MotionEvent.getRawX()/getRawY()(display-absolute coordinates) for focal point and movement delta calculationsMapViewreportsgetLocationOnScreen() = (0, 0)even when it has a significant display offset, so the SDK cannot correct for the difference between raw and local coordinatesMapSurface#surfaceChangednot updating dimensions for plugins) and related to issue #2131 (coordinate projection issues)Our workaround: We intercept touch events via
setOnTouchListenerand create correctedMotionEventcopies (usingMotionEvent.obtain()withPointerCoordsfromgetPointerCoords()) wheregetRawX() == getX(), then dispatch the corrected event toMapView.onTouchEvent(). This resolves the issue for all gesture types.A proper SDK fix would likely involve the gesture detectors using view-relative coordinates (
getX()/getY()) instead ofgetRawX()/getRawY(), or correctly accounting for the view's screen position when computing focal points.Additional links and references