Fix crash on startup due to directionMarker/directionMarkerSize race condition #638
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.
I've been getting this error on startup of StreetComplete a few times:
It seems it is because
directionMarker
is not null, butdirectionMarkerSize
is null inonRotationChanged
in app/src/main/java/de/westnordost/streetcomplete/tangram/MapFragment.java.Rearranging the initialisation in
initMarkers
so thatdirectionMarkerSize
is set beforedirectionMarker
is should solve the problem, even ifonRotationChanged
is called duringinitMarkers
, which does seem to happen for me, at least some of the time.My instinct is telling me to set up all of the markers in local variables first, then assign them to the class so that they are either fully initialised or null when listeners fire, but I haven't gone that far here, just yet.
I've run this a few times, and it hasn't crashed yet, which it would do before semi-often. I'll run this over the next few days to be sure, though.