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

Fix share logs dialog blocks to prevent weird context switching blocking the share dialog #1282

Closed
wants to merge 3 commits into from

Conversation

0x330a
Copy link

@0x330a 0x330a commented Jul 27, 2023

Tested on Samsung device that was preventing share dialog properly showing the chooser intent.

calls to requireContext() or referenced the context of the dialog were being used after the dismissal of the dialog, leading to a detached context error

cancelButton { dismiss() }
}

private fun shareLogs() {
shareJob?.cancel()
shareJob = lifecycleScope.launch(Dispatchers.IO) {

Choose a reason for hiding this comment

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

Was it still useful to schedule the work?

could move it down, so it is just around the actual IO, and grab a reference to ApplicationContext around here first.

Copy link
Author

Choose a reason for hiding this comment

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

I tried to turn this into a suspending function and run the shareLogs() call in a runBlocking { } block, but then it was getting a LifecycleScope cancellation in the job itself, while also having some weird issues around context switching trying to launch the chooser intent. I'm not sure if it was easier to just run it this way since the only way I could get the job to run properly was to basically block the main thread the equivalent way 🤷

…ismiss when button listeners are triggered, change the share logs dialog to operate on main thread and switch context when generating files instead
@bemusementpark
Copy link

Fixed with minimal code changes in #1295 as discussed.

@0x330a 0x330a deleted the fix-share-logs branch August 8, 2023 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants