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

Unexpected safe area insets on CarPlayNavigationViewController #4479

Open
johnnewman opened this issue Jun 15, 2023 · 2 comments
Open

Unexpected safe area insets on CarPlayNavigationViewController #4479

johnnewman opened this issue Jun 15, 2023 · 2 comments
Labels
bug Something isn’t working

Comments

@johnnewman
Copy link

johnnewman commented Jun 15, 2023

Mapbox Navigation SDK version

2.13.0 and 2.11.0

Steps to reproduce

Hello! I'm using Xcode 14.3.1 with an iOS 16.4 simulator. I've also seen this issue on a physical device.

  1. Run the Example-CarPlay project.
  2. Disable route simulation.
  3. Set the simulator on the "Freeway Drive" location.
  4. Drop a pin anywhere and start navigation with a CarPlay window active.
  5. Occasionally tap the map to open the navigation bar and/or open the feedback UI.

Keep an eye on the current street label and camera's position relative to the user puck.

Safe.Areas.mov

Expected behavior

The leading and trailing safe area insets stay consistent and don't briefly change values.

Actual behavior

Every so often, the CarPlayNavigationViewController's viewSafeAreaInsetsDidChange gets called with incorrect/unexpected insets that don't account for the necessary horizontal safe areas of the CarPlay window. When this happens, the map's camera will center the puck on the whole screen, causing it to partially draw under the maneuver UI. The current street label will also draw underneath the maneuver UI.

This seems to arise more frequently when the navigation bar is presented after tapping on the screen or after dismissing the feedback UI. After a moment, viewSafeAreaInsetsDidChange will be called with the expected values and the UI will correct itself.

I'm not sure if this is something related to the SDK itself, or if this is a bug within Apple's CarPlay framework. I'm curious if anyone has leads. I've seen this issue within the Mapbox Navigation SDK inside my own CarPlay app as well, which does not have a feedback button and instead displays a pan button at that position.


I've been able to capture the bug in logs by inserting one print statement in CarPlayNavigationViewController:

public override func viewSafeAreaInsetsDidChange() {
    ... <existing implementation here> ...

    print("Safe area insets did change \(view.safeAreaInsets)")
}

Using the default CarPlay simulator size:

  • when the UI is acting as expected, the edge insets looks like UIEdgeInsets(top: 44.0, left: 195.0, bottom: 0.0, right: 38.0)
  • when the bug arises, the insets change to UIEdgeInsets(top: 44.0, left: 45.0, bottom: 0.0, right: 0.0).

You can see the horizontal safe area is incorrect, particularly on the left side. Thank you for the assistance!

Is this a one-time issue or a repeatable issue?

repeatable

@johnnewman johnnewman added the bug Something isn’t working label Jun 15, 2023
@Udumft
Copy link
Contributor

Udumft commented Jun 23, 2023

Hi, @johnnewman, and thank you for reporting this one and making your own investigation! We'll take a look on that issue and update the ticket when it's done

@ClockWise89
Copy link

Hi, I also use CarPlay navigation in my app, and had a similar issue where the safeAreaLayout changed repeatedly without actually presenting anything on the screen to motivate the change. In my case it only happened after I started and ended a first navigation session. So it worked as expected the first navigation, and every navigation henceforth caused numerous viewSafeAreaInsetsChanged() calls.

The problem was memory leaks in the navigation sessions handling. The sessions weren't cleared up after finishing, causing multiple map updates. So if I started a navigation, ended it, and started a new one, I was beeing fed updates for two ongoing navigations, which seems to have been the root cause for the safeAreaLayout changes. I don't use Mapbox but thought it might be the same anyways. Hope this helps someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

No branches or pull requests

3 participants