0
0
Fork
You've already forked comaps
0
forked from comaps/comaps

[carplay] Fix background GPS leak and render crash after a wireless teardown #22

Open
eisa01 wants to merge 1 commit from carplay-0704-findings into testflight/2026.06.30
pull from: carplay-0704-findings
merge into: eisa01:testflight/2026.06.30
eisa01:main
eisa01:eisa01/carplay-road-shields
eisa01:multi-surface-map-rendering
eisa01:carplay-dashboard-support
eisa01:modes-ui
eisa01:carplay-0708
eisa01:forgejo-macos-runner
eisa01:create-venv
eisa01:carplay-0706
eisa01:fable-review
eisa01:testflight/2026.06.30
eisa01:carplay-dashboard
eisa01:carplay-om-code-review
eisa01:carplay-code-review-jun28
eisa01:carplay-dashboard-mvp2
eisa01:car-follow-on-reacquire
eisa01:carplay-location-keepalive
eisa01:testflight/2026.06.20
eisa01:carplay-roundabout-exit-number
eisa01:carplay-destination
eisa01:carplay-dashboard-mvp
eisa01:name-cherry-picking
eisa01:om-pr-11243-2
eisa01:icu-cjk-fix
eisa01:simple-cjk-fix
eisa01:fix-crash-search
eisa01:scene-support
eisa01:om-carplay-button
eisa01:om-pr-10545
eisa01:submodule-main-branch
eisa01:improve-unit-testing-docs

Description

Fix issue

Submitter checklist

  • All code changes and commit messages conform to the appropriate style guide
  • I have signed off all my commits with the Developers Certificate of Origin
  • All communication (commit messages, pull request messages, documentation, and code comments) is human written and not authored by AI
  • I take full responsibility of all changes submitted in this pull request
### Description Fix issue ### Submitter checklist - [x] All code changes and commit messages conform to the appropriate [style guide](https://codeberg.org/comaps/comaps/src/branch/main/docs/CONTRIBUTING.md#code-contributions) - [x] I have signed off all my commits with the [Developers Certificate of Origin](https://codeberg.org/comaps/Governance/src/branch/main/DCO.md) - [x] All communication (commit messages, pull request messages, documentation, and code comments) is human written and not authored by AI - [x] I take full responsibility of all changes submitted in this pull request
Field testing 2026年07月04日 (wireless CarPlay, TestFlight 2026年07月02日-1)
surfaced two bugs with one shared trigger. Wireless CarPlay drops the
session only after the user has walked away from the car, so the
grace-period teardown (destroy(), 2s after the scenes disconnect) now
always runs while the app is already backgrounded — an ordering a cabled
disconnect never produced, and one the teardown-debounce work had not
accounted for.
Bug 1: location never stopped after the trip ended. The blue location
indicator stayed on and the app kept consuming GPS in the background
for 16+ minutes until force-quit. keepRunningInBackground() is only
evaluated on resign-active, and at that moment the car screen still
hosts the map, so location legitimately keeps running. When destroy()
ends the hosting two seconds later, nothing re-evaluated the policy, so
started/allowsBackgroundLocationUpdates stayed YES indefinitely. Fix:
destroy() now calls the new
+[MWMLocationManager reapplyBackgroundLocationPolicy], which re-runs
the keepRunningInBackground() decision iff the app is backgrounded
(when it is foreground, applicationDidBecomeActive owns the state).
Navigation continuing on the phone and GPS track recording still keep
location on — the policy predicate is unchanged.
Bug 2: EXC_BAD_ACCESS on the drape frontend render thread, three field
crashes with the identical stack (dp::ApplyState → ApplyTexturesForMetal
under FrontendRenderer::RenderFrame; symbolicated crash 2026年07月04日
17:42:30). All three followed a destroy() that ran while backgrounded:
the phone-appearance restore (setCarScreenMode, position arrow offset,
CarPlayWindowScaleAdjuster → UpdateVisualScale) executed while rendering
was disabled, so the Metal surface/texture rebuild that normally follows
a visual-scale or style switch could not happen. The first frames
rendered after resuming — a phone foreground (2 crashes) or a CarPlay
reconnect 12s later (1 crash, mid-drive, auto-relaunched) — drew render
groups whose textures had been freed.
Fix: the host appearance work is consolidated into
applyHostAppearanceIfActive(), derived from the current mapHost. While
the app is backgrounded it only records that a refresh is due; the
appearance is applied on the next UIApplication.didBecomeActive (via a
dispatch to the next runloop turn so MapsAppDelegate's appDidActivate
has re-enabled rendering first, regardless of observer order). Because
the pending state is re-derived from mapHost at apply time, a
background bounce carplay → none → carplay collapses into applying the
final host's appearance once — the map no longer flips styles/scales
invisibly in the background. The cheap UIKit reparenting
(enable/disableCarPlayRepresentation, add/removeMapView) stays
immediate so the shared map view is never orphaned in a dead window.
setup()'s redundant car-mode/arrow-offset reassertion is routed through
the same helper, and attachMapToCarScreen loses its now-unused window
parameter.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: eisa01 <eisa01@gmail.com>
eisa01 force-pushed carplay-0704-findings from 2173e91628 to 0d866147b3 2026年07月06日 14:44:25 +02:00 Compare
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin carplay-0704-findings:carplay-0704-findings
git switch carplay-0704-findings

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch testflight/2026.06.30
git merge --no-ff carplay-0704-findings
git switch carplay-0704-findings
git rebase testflight/2026.06.30
git switch testflight/2026.06.30
git merge --ff-only carplay-0704-findings
git switch carplay-0704-findings
git rebase testflight/2026.06.30
git switch testflight/2026.06.30
git merge --no-ff carplay-0704-findings
git switch testflight/2026.06.30
git merge --squash carplay-0704-findings
git switch testflight/2026.06.30
git merge --ff-only carplay-0704-findings
git switch testflight/2026.06.30
git merge carplay-0704-findings
git push origin testflight/2026.06.30
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
eisa01/comaps!22
Reference in a new issue
eisa01/comaps
No description provided.
Delete branch "carplay-0704-findings"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?