-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Mobile] Fix crash on undefined image url #15532
[Mobile] Fix crash on undefined image url #15532
Conversation
👋 @mkevins , I wonder, is that combination a valid state? If not, maybe we also need to try to set the block to a valid state? |
I don't think this state is "valid". I've added some commits to set |
I've been chatting with @mkevins and helped a bit testing and finding other flows that can result in attributes.id being set, while attributes.url is null, and didn't find another flow yet. |
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.
Hey @mkevins, I have left some comment but besides that, it's great to work here!
So be free to merge this PR when you resolve the comment.
a93d005
into
rnmobile/master-fork-before-richtext-selection-state-change
Thank you @daniloercoli and @marecar3 for testing and reviewing! |
I was looking at the code and it seems intentional and valid to me. The This is just from a static analysis though, I haven't debugged this to validate, but I imagine @SergioEstevao will be able to confirm or deny this 😄 |
Hey @koke I think that @mkevins solution is good. When a user clicks on the Also, a failed state is different then cancel state as it can retry uploading. Btw, I found some bug on iOS regarding failed upload wordpress-mobile/gutenberg-mobile#978 cc : @SergioEstevao |
Considering the changes in #966, it’s not clear to me whether canceling would automatically bring the state back to placeholder, or allow to retry. But a failed upload would have a failed state where having the media ID still makes sense. We could eventually decide something different, but that is why I think this is considered a valid state on the iOS code. |
Not sure if the link is good (#966), but I agree with your thoughts :) |
Ah, wrong repo 😂 |
Description
This PR adds a check to ensure
attributes.url
exists before attempting to callindexOf
. Currently, there are scenarios which can result inattributes.id
being truthy, whileattributes.url
isnull
orundefined
for an image block.When an image is cancelled before it is finished uploading, the
url
is set tonull
, but theid
of the block remains. The next time the post is edited, the local draft will contain the state which triggers the crash.How has this been tested?
This was tested using the steps here: wordpress-mobile/WordPress-Android#9768 (comment)
Types of changes
This is a bug fix for the crash discovered here: wordpress-mobile/WordPress-Android#9768
Checklist: