Fix MapboxNavigation#detach issue#6245
Merged
Merged
Conversation
kmadsen
commented
Aug 30, 2022
| services.forEach { it.onDetached(mapboxNavigation!!) } | ||
| MapboxNavigationProvider.destroy() | ||
| mapboxNavigation = null | ||
| logI("disabled ${services.size} observers", LOG_CATEGORY) |
Contributor
Author
There was a problem hiding this comment.
Adding this log because it is useful to figure out how many services are attached when you call disable.
Codecov Report
@@ Coverage Diff @@
## main #6245 +/- ##
============================================
+ Coverage 68.84% 68.86% +0.01%
- Complexity 4336 4338 +2
============================================
Files 650 650
Lines 26102 26104 +2
Branches 3061 3061
============================================
+ Hits 17971 17976 +5
+ Misses 6968 6965 -3
Partials 1163 1163
|
Zayankovsky
approved these changes
Aug 31, 2022
Comment on lines
60
to
+63
| attached = false | ||
| services.forEach { it.onDetached(mapboxNavigation!!) } | ||
| MapboxNavigationProvider.destroy() | ||
| mapboxNavigation = null |
Contributor
There was a problem hiding this comment.
This is repeated in carAppLifecycleObserver.onStop, looks like it should be moved to a separate function.
Contributor
Author
There was a problem hiding this comment.
there are still some slight differences like logs and the condition for if (attached)
think i prefer to let them continue to be separate, cover the issues with tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Found this issue while testing this #6233
mapboxNavigationis still valid after callingdetach. This means all calls tocurrent()will return non-null, and if you unregister an observer it can result detach calls after it has been disabled. It is expected, to have a single onDetached call per every onAttached.I separated this pull request from 6233 because it would definitely impact anyone using
detach.