-
Notifications
You must be signed in to change notification settings - Fork 314
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
Carplay map interactions stop working when phone goes to sleep mode #1774
Comments
@margvl unfortunately, interaction on CarPlay works when the screen is unlocked. CarPlay interprets the app to have entered a background or suspended state. Ideally, the 3rd-party developer would have to manage how to react to those aforementioned states and the interaction with CarPlay. |
@vincethecoder CarPlay interaction works when screen is locked as well, but MGLMapView ignores setZoomLevel or setCenter calls, maybe others as well but I have not checked... I looked into other navigation apps like Google Maps, Apple Maps and Waze. None of them have such issue. Are you sure that this is expected behaviour for MapBox navigation? |
@margvl I plan to further investigate and fill you in with my findings shortly. |
@vincethecoder I will look forward for a results! |
It appears that one needs physical hardware to reproduce this issue — the buttons in the demo app behave as expected with a “locked” Simulator + CarPlay external display. |
@friedbunny yes, that's correct! Let me know if you would like to pair on resolving this issue in Maps. @julianrex and I paired initially to discuss solutions to this issue. |
@vincethecoder Hello, since some time passed I would like to know if there was any progress regarding this issue. |
@julianrex do we have any status update for @margvl? |
It's on our list - but I don't have any other update right now, other than to say it's a high priority item for us. |
@julianrex Hi, maybe you have more details to elaborate about this issue? Maybe you home some information about approximate time when is planned to start working on it. |
It feels too easy, but the following patch in the map SDK allows the CarPlay example application to continue to simulate navigation (complete with an animating map) while the phone is manually locked and connected to a CarPlay hardware device: diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 52bf4e83f5..9899e0cf36 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -1222,7 +1222,7 @@ public:
self.mbglMap.setConstrainMode(mbgl::ConstrainMode::HeightOnly);
}
- _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateFromDisplayLink)];
+ _displayLink = [self.window.screen displayLinkWithTarget:self selector:@selector(updateFromDisplayLink)];
[self updateDisplayLinkPreferredFramesPerSecond];
[_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
_needsDisplayRefresh = YES;
@@ -1301,6 +1301,9 @@ public:
- (void)sleepGL:(__unused NSNotification *)notification
{
+ if (self.window.screen != [UIScreen mainScreen]) {
+ return;
+ }
MGLLogInfo(@"Entering background.");
MGLAssertIsMainThread();
To wit, I short-circuited the map SDK’s workaround for mapbox/mapbox-gl-native#1460 based on whether the MGLMapView instance is rendering headlessly, and I ensured that the MGLMapView’s redrawing is driven by a display link created for the correct screen. Note that the CarPlay example application already has the /cc @nitaliano |
That’s great news. I was pretty confident that the DisplayLink was part of the problem, but I’m pleasantly surprised that the solution seems to be as simple as just that. Thanks @1ec5 for digging into this! |
This issue was fixed in mapbox/mapbox-gl-native#13701, but the fix won’t show up in the navigation SDK until the next map SDK release. A beta release of the map SDK is coming soon that CocoaPods users can manually specify in place of the latest official version. |
Mapbox Navigation SDK version:
0.22.1
Steps to reproduce:
Run example-carplay app
Press a power button on device to go black screen
Zoom in/Zoom out/Pan
Expected:
All interactions should work
Actual:
Buttons are not working
I created a short video with steps how to reproduce:
https://www.dropbox.com/s/4g61y61ubd7ro3w/IMG_0068.MOV?dl=0
Reproduced using iPhoneX iOS version 12.0 and Multimedia JVC KW-M730BT
The text was updated successfully, but these errors were encountered: