This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Fixed image picker crash when used with android alarm manager #1125
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will prevent the crash but IIUC leaves us with an unregistered plugin, as even if the activity asks the GeneratedPluginRegistrant to register again it will short circuit.
Unless I'm missing something this will trade the startup crash with a crash the first time the plugin is used (as the method channel isn't registered).
I believe the only eager use of activity is getExternalFilesDir and this can be done with the application context which is guaranteed to be available.
It looks like ImagePickerDelegate is caching the activity that's being passed to it from here, I believe instead of doing that we can make ImagePickerDelegate always ask the activity from the registrar when it needs an activity.
@cyanglaz @Hixie am I getting this wrong? is the current fix actually leaving the picker in a working state? are you interested in merging this for now just to prevent the early crash or doing a little more refactoring here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how to test if the picker was in a working state with this fix -- the problem I was seeing was that when the app was starting in the background (for the alarm manager), nothing was working, because the plugin would crash and prevent anything else from happening. In that case, I don't actually care about the image picker.
I've no idea if it's possible for the app to then get re-used in the foreground. If so, then I agree that this wouldn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point for the scenario that the app is executed in the background and then quits (and the Android APP is destroyed) it's ok to live with the plugin unregistered. So this fix at least improves some cases, we can land it now. We should probably follow-up and figure what happens if e.g the app's background code is calling startActivity and starts an activity of the same (Android) application with a FlutterView.