Repository navigation
Declare the mute durations before the settings view model's init - #2274
Draft
mpretty-cyro wants to merge 1 commit into
Draft
mpretty-cyro wants to merge 1 commit into
mpretty-cyro wants to merge 1 commit into
Conversation
The init block's collector runs on Dispatchers.Default and can reach updateState before the constructor initialises properties declared after it, so opening notification settings for a muted conversation could read a null muteDurations and crash.
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.
Contributor checklist
playflavour,qaFixes #1234syntaxDescription
Crash cluster in 1.33.9:
NullPointerExceptioninNotificationSettingsViewModel.updateStatemappingmuteDurations(6 users / 6 events). The code is unchanged since before 1.33.7.The
initblock starts collecting the recipient onDispatchers.Default, and the first emission can callupdateStatebefore the constructor has run the initialisers of properties declared afterinit. For a muted conversationupdateStatebuilds the mute options frommuteDurations, which was declared at the bottom of the class and could still be null. MovingmuteDurationsanddebugMuteDurationsaboveinitmakes them initialised before the collector starts. Nothing else is changed.Confidence: high.
Testing: muted a 1:1 conversation for an hour, then opened its notification settings eleven times. Each time it showed "Muted until …" and the full list of mute durations, with no crash. The race itself, the collector winning against the constructor, was not reproduced.