mapbox-maps-ios icon indicating copy to clipboard operation
mapbox-maps-ios copied to clipboard

Offscreen view-based annotations draw along the edge of the map

Open johnnewman opened this issue 2 years ago • 2 comments

Environment

  • Xcode version: 13.4.1
  • iOS version: 15.5
  • Devices affected: iPhone and iPad
  • Maps SDK Version: seen on 10.7.0 and 10.8.0
    • I have not been able to reproduce this on SDK 10.6.1 or earlier.

Observed behavior and steps to reproduce

Using the MapView's viewAnnotations.update(_:options:) API, when a view-based annotation has its coordinate updated to a coordinate that's offscreen, it can sometimes render at the wrong location along the edge of the map's bounds. This often overlaps the visible viewport of the map's camera, causing the annotation to appear at the wrong location.

This is evident in my app because I draw a custom view-based annotation for the user avatar. It is a common use case in my app to keep the user's avatar in sync with the user's location via the LocationConsumer protocol. Because of this, any time the user pans the map away from their current location, their avatar risks drawing at the edge of the map viewport.

Expected behavior

Similar to SDK 10.6.1 and earlier. When a view-based annotation has its coordinate updated via the viewAnnotations.update(_:options:) API, it doesn't render along the edge of the map's bounds unless its coordinate is along the edge.

Notes / preliminary analysis

Here is a gist with the necessary code for reproducing this issue. This is the code used to capture the below gif.

Additional links and references

Here is an example where I draw a red annotation view at the center of the US. When I pan the map away, the annotation will render at the edge of the screen.

view-based annotation bug

johnnewman avatar Sep 08 '22 22:09 johnnewman

@johnnewman thank you for reporting this. We will investigate the root cause and get back to you as soon as we can.

ZiZasaurus avatar Sep 12 '22 14:09 ZiZasaurus

Same issue: xcode: 14.0.1 iOS 16.0.2 SDK: 10.8.1

wmurmann avatar Oct 02 '22 22:10 wmurmann

@johnnewman this behavior has been resolved in v10.9.

ZiZasaurus avatar Oct 24 '22 14:10 ZiZasaurus

Thank you @ZiZasaurus!

johnnewman avatar Nov 08 '22 18:11 johnnewman

This is still happening for me on v10.9.1

wmurmann avatar Nov 12 '22 01:11 wmurmann

@ZiZasaurus this issue is still occurring for me in v10.9.1 as well. Can you reopen this ticket?

Below is a screen recording using the gist from the description.

  • The view-based annotation first appears in the top left corner when the app starts. [bug]
  • When I pan to the view's coordinate, it moves from the corner to its expected location.
  • When I pan away, the annotation "sticks" to the edge of the screen. [bug]

https://user-images.githubusercontent.com/1591735/202769753-5ac3eee6-da17-480d-a826-6619504f1926.mov

johnnewman avatar Nov 18 '22 17:11 johnnewman

After trying again on v10.10.0-rc.1, this bug appears to be fixed!

johnnewman avatar Nov 22 '22 15:11 johnnewman

@johnnewman you're an absolute lifesaver for pointing this out. View annotations are a core part of my app and they were acting incredibly erratically. Now they're perfect :).

maxmiranda avatar Feb 17 '23 05:02 maxmiranda