Skip to content

fix: keep the screen on during active guidance - #26

Merged
mfazekas merged 1 commit into
mainfrom
keep-screen-on-during-guidance
Oct 29, 2026
Merged

mfazekas merged 1 commit into
mainfrom
keep-screen-on-during-guidance

Conversation

@mfazekas

Copy link
Copy Markdown
Contributor

Active guidance didn't keep the screen on. Only the iOS SDK's NavigationViewController (and CarPlay) disables the idle timer, so guidance on a navigation map (mapViewImpl="rnmbxnav", <RNNavigationView>) on both platforms and Android's <NavigationView> let the phone sleep mid-trip. On iOS, <NavigationView> also reset isIdleTimerDisabled to false on close, clobbering apps that set it themselves. Same request as googlemaps/react-native-navigation-sdk#302.

The fix lives in the session, since guidance is process-wide and can run without any view: it keeps the screen on from startActiveGuidance (or <NavigationView> starting guidance) until stopNavigation / unmount, and then restores what the app had.

  • iOS: saves isIdleTimerDisabled, sets it to true, and puts the saved value back afterwards. <NavigationView> sets shouldManageApplicationIdleTimer = false, so the session is the only owner (the SDK's manager always writes false when done).
  • Android: sets keepScreenOn on the activity's decor view rather than FLAG_KEEP_SCREEN_ON on the window, so apps (or expo-keep-awake) that use the window flag are untouched. It's reapplied on host resume in case the activity changed.
  • Navigation.setKeepScreenOn(false) opts out, like the SDK's shouldManageApplicationIdleTimer. It's on by default.

Verified on an iOS 26.5 simulator (reading UIApplication.shared.isIdleTimerDisabled with lldb) and an API 36 emulator (dumpsys window / dumpsys power, with screen_off_timeout set to 15 s during simulated guidance):

Surface Before After
iOS navigation map, <RNNavigationView> NO while guiding YES while guiding, NO after stop
iOS <NavigationView>, app had set YES NO after close YES after close
Android navigation map, <NavigationView>, <RNNavigationView> no KEEP_SCREEN_ON, mWakefulness=Asleep within 30 s KEEP_SCREEN_ON and the WindowManager screen wake lock, still Awake after 40 s; cleared on stop
setKeepScreenOn(false), both platforms n/a not kept on

Lint, typecheck and tests pass.

Guidance on navigation maps (both platforms) and in Android's
<NavigationView> let the screen sleep mid-trip, and iOS <NavigationView>
reset an app's own isIdleTimerDisabled to false when it closed.

The session now keeps the screen on while guidance runs and restores the
app's previous setting when it stops. Navigation.setKeepScreenOn(false)
opts out.
@mfazekas
mfazekas force-pushed the keep-screen-on-during-guidance branch from 3b8397b to bf3776f Compare October 28, 2026 23:56
@mfazekas
mfazekas marked this pull request as ready for review October 29, 2026 00:55
@mfazekas
mfazekas merged commit 9ba16b4 into main Oct 29, 2026
6 checks passed
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 this pull request may close these issues.

1 participant