Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect against onResume running in MainMenuActivity during crash flow #5679

Merged
merged 3 commits into from
Jul 18, 2023

Conversation

seadowg
Copy link
Member

@seadowg seadowg commented Jul 17, 2023

Fixes this crash.

The crash is fairly rare, but I ended up fixing it while investigating.

What has been done to verify that this works as intended?

New tests.

Why is this the best possible solution? Were any other approaches considered?

I didn't think we'd need to do this, but it seems like some devices might call onResume after an onCreate that calls finish and the fact that this is reproducible in Robolectric definitely backs that up.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

The only thing affected is the flow when reopening the app after a crash, so that would be good to play with.

Before submitting this PR, please make sure you have:

  • run ./gradlew checkAll and confirmed all checks still pass OR confirm CircleCI build passes and run ./gradlew connectedDebugAndroidTest locally.
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

This should not happen as far as we understand, but seems to be
occuring in the wild on some devices and is also reproducible
in Robolectric
@seadowg seadowg changed the base branch from master to v2023.2.x July 17, 2023 16:50
@seadowg seadowg changed the title Protect against onResume running in MainMenuActivity during crash flow Protect against onResume running in MainMenuActivity during crash flow Jul 17, 2023
@seadowg seadowg marked this pull request as ready for review July 17, 2023 16:54
@seadowg seadowg added this to the v2023.2.x milestone Jul 17, 2023
CrashHandler.getInstance(application)!!.registerCrash(application, IllegalStateException())

val activity = Robolectric.setupActivity(MainMenuActivity::class.java)
assertThat(shadowOf(activity).nextStartedActivity, notNullValue())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we also check that the new activity is CrashHandlerActivity as the title says? Here you just check if it's not null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! Yes absolutely.

@grzesiek2010
Copy link
Member

@seadowg
do you want the QA team to test this pr? I'm ok with merging right away even without testing so you can decide.

@seadowg
Copy link
Member Author

seadowg commented Jul 18, 2023

I'm ok with merging right away even without testing so you can decide.

I haven't found an on device way to reproduce, so yeah I'm going to go ahead and merge.

@seadowg seadowg merged commit 7748e5b into getodk:v2023.2.x Jul 18, 2023
@seadowg seadowg deleted the on-resume branch July 18, 2023 14:03
@lognaturel
Copy link
Member

@seadowg, still occurs in .3 (here)

seadowg added a commit to seadowg/collect that referenced this pull request Jul 28, 2023
Protect against `onResume` running in `MainMenuActivity` during crash flow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: done
Development

Successfully merging this pull request may close these issues.

3 participants