-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[Gutenberg] Fix crash when showing media upload dialog #18544
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
[Gutenberg] Fix crash when showing media upload dialog #18544
Conversation
|
| App Name | WordPress |
|
| Flavor | Jalapeno | |
| Build Type | Debug | |
| Version | pr18544-47c5a52 | |
| Commit | 47c5a52 | |
| Direct Download | wordpress-prototype-build-pr18544-47c5a52.apk |
|
| App Name | Jetpack |
|
| Flavor | Jalapeno | |
| Build Type | Debug | |
| Version | pr18544-47c5a52 | |
| Commit | 47c5a52 | |
| Direct Download | jetpack-prototype-build-pr18544-47c5a52.apk |
Generated by 🚫 dangerJS |
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.
👋 @fluiddot !
I have reviewed and tested this PR as per the instructions (great set of instructions btw), everything works as expected (good job on finding and fixing this btw)! 🌟 🌟 🌟
EXTRAS:
- Question (❓): I have just one question, I am seeing this block of similar
AlertDialog.Builderrelated code to have been existing since13/6/20, which seems to be guarding against such pre-existing crashes (with agetActivity().runOnUiThread(...)block, plus this and this for toasts). I wonder how come with was done 3 years ago, but similar thread switches weren't added to the rest of such dialog functionality... 🤔 - Question (❓): Having gotten this crash it makes me also wonder if we might have other such crashes in other places of the app, or else, whether this is specific to GB because of the way
OnMediaLibraryButtonListener,OnMediaFilesCollectionBasedBlockEditorListenerand other such listeners are setup, running on background and then returning to main thread. Can you help me clear any doubts about how this is set-up and working, just as an FYI and so that we can maybe figure out if other screens of the app can be impacted like that. 🙏 - Suggestion (💡): I am also wondering whether we should consider adding the @UiThread annotation to such methods (like
showRetryMediaUploadDialog(...)) just to indicate to the caller that they should be called viagetActivity().runOnUiThread(...)to avoid potential crashes, that is, they the same methods gets called from elsewhere, not sure... 🤔
|
I went through the test cases using a Samsung Galaxy A23 5G (Android 13) and it works as expected 🚀 Thank you! |
b80afc6 to
47c5a52
Compare
|
Thanks @ParaskP7 for reviewing and testing the PR ❤️ !
Good question, and to be honest I wondered the same when working on the fix 😅. I'm afraid I can't tell why it was done for some parts and not for others, maybe the ones that have the guards were introduced more recently and we identified the potential crash 🤷♂️ .
I'm not sure if this issue could be affecting other areas of the app. I mainly tested Gutenberg but also checked the classic editor (Aztec editor) as it also displays a dialog. However, it worked as it's executed in the main thread. In the case of Gutenberg, this is produced by how the React Native bridge works. The calls from the Javascript side to execute code on the native side are done in a separate thread for the native modules. This means that all intents to show a dialog from the editor's logic need to be guarded against this issue. This gives me the impression that this crash is more likely to happen in the editor than in other areas of the app, but we can't truly tell without investigating further.
Ah, interesting, thanks for sharing this. I've updated the PR with this suggestion (47c5a52) 👍. |
@ParaskP7 I tested using the annotation and calling one of the updated functions without the guard and I haven't received any warning or error. Not sure if there's anything else we should incorporate to avoid the crash in the future 🤔. I understand that adding the annotation won't have any undesired side effect to the fix, hence I'll keep it and proceed with merging the PR. |
|
👋 @fluiddot , thanks for the reply and adding @UiThread! 🥇
👍 🤷 😃
Thanks for checking! 💯
Ah, this now makes much more sense to me, thanks for explaining! 🎯
I agree! 💯
Awesome, thanks for applying this suggestion, I have reviewed the change and everything LGTM! ✅
Yes, you are right, it doesn't give you a warning, but it is at least a good indication for someone that would try and use this method in the future, or a reviewer that will take a look at that code change, potentially catching a crash if that is not guarding with Though, I agree that a warning would have been much much nicer... 🤷 FYI: Feel free to merge this at your earliest convenience and again, many THANK for identifying and fixing this! ❤️ 🚀 |
|
Sentry issue: WORDPRESS-ANDROID-2N93 |


Fixes a crash in the editor related to the dialog shown as part of the upload process. Specifically, the ones displayed when trying to cancel or retry an upload (p5T066-41d-p2#comment-14730).
Error displayed in development mode:

After merging #18364, seems that some of the upgraded dependencies (probably
activity), require theDialogcomponent to be called from the main thread when showing it. This PR updates the React Native bridge code that handles showing upload dialogs.To test
Cancel dialog - Upload for media
Retry dialog - Upload for media
Cancel dialog - Upload for media collection (only used in Story block)
Retry dialog - Upload for media collection (only used in Story block)
Regression Notes
Potential unintended areas of impact
N/A
What I did to test those areas of impact (or what existing automated tests I relied on)
N/A
What automated tests I added (or what prevented me from doing so)
N/A
PR submission checklist:
RELEASE-NOTES.txtif necessary.UI Changes testing checklist: