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

Carplay map interactions stop working when phone goes to sleep mode #1774

Closed
margvl opened this issue Oct 12, 2018 · 13 comments · Fixed by mapbox/mapbox-gl-native#13701
Closed

Comments

@margvl
Copy link

margvl commented Oct 12, 2018

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

@vincethecoder vincethecoder self-assigned this Oct 12, 2018
@vincethecoder
Copy link
Contributor

vincethecoder commented Oct 12, 2018

@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 vincethecoder removed their assignment Oct 12, 2018
@margvl
Copy link
Author

margvl commented Oct 15, 2018

@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?

@vincethecoder
Copy link
Contributor

@margvl I plan to further investigate and fill you in with my findings shortly.

@margvl
Copy link
Author

margvl commented Oct 19, 2018

@vincethecoder I will look forward for a results!

@friedbunny friedbunny removed their assignment Oct 30, 2018
@friedbunny
Copy link
Contributor

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.

@vincethecoder
Copy link
Contributor

@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.

@margvl
Copy link
Author

margvl commented Nov 12, 2018

@vincethecoder Hello, since some time passed I would like to know if there was any progress regarding this issue.

@vincethecoder
Copy link
Contributor

vincethecoder commented Nov 12, 2018

@julianrex do we have any status update for @margvl?

@julianrex
Copy link
Contributor

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.

@margvl
Copy link
Author

margvl commented Nov 27, 2018

@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.
I curious because it is huge blocker for our project right now...

@1ec5
Copy link
Contributor

1ec5 commented Jan 10, 2019

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 audio and location background modes, as required in the navigation SDK’s setup instructions. (I was getting voice instructions while the phone was locked, as expected.)

/cc @nitaliano

@akitchen
Copy link
Contributor

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!

@1ec5
Copy link
Contributor

1ec5 commented Jan 14, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants