-
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
Gallery block: Some images point to local URLs when closing the post with ongoing uploads #33593
Gallery block: Some images point to local URLs when closing the post with ongoing uploads #33593
Comments
I managed to reproduce this issue on Android too by adding a big batch of images and re-opening the post while the uploads are ongoing. It's harder to reproduce but I saw some images pointing to |
Thanks for the detailed report @fluiddot !
👍 This sounds like wordpress-mobile/gutenberg-mobile#1526. |
Right, as per that issue description, it looks like it's the same issue. |
This issue is in fact related to a race condition between closing the post and images already uploaded, here is an example of a test I made that proves it: Preparation:
StepsThe steps followed in the tests are:
ResultsXcode console
Post HTML
Image upload status:
As you can see the images were uploaded but one is pointing to a local URL ( Potential workarounds
|
Good investigation here @fluiddot I want to add some context here that is related to the point below.
When working on the Audio block we had to create processors in both platforms that detected the local URLs and replaced them with the remote versions. wordpress-mobile/WordPress-Android#13575
I am guessing based on your explanation above we may need to do some optimizations to the serialization process or optimize the processors to support this case.
Does this mean sometimes the local URLs are replaced and other times they are not? I am guessing the latter is the case.
Ah, this is quite interesting! |
Thanks @jd-alexander for the info 🙇 , I learned about the existence of the processors while testing, I haven't explored further how they work but I have a rough idea. As far as I investigated, the media that ends up with the local URL is not actually processed because technically it's already uploaded (see the explanation for this below).
Not exactly, all media items that are being uploaded or pending upload are properly processed and their local URLs are replaced. However, there's a case where some media items have just finished the upload while the post is being closed, which would imply that they won't be processed on the native side because they're considered already uploaded. In theory, since the upload is completed the URL should be correct but unfortunately, it's not because the editor serialized the HTML that will be saved before the upload complete events are received on the RN side. |
On iOS, I noticed that in case there are no media items being uploaded when saving a post, it actually updates the URL because it processes all current media items of the post 🤔 . So a potential solution would be to process completed media items when the post is uploading media, or process all items once the uploads have finished. On Android looks like it always processes all media items, here I listed the methods involved in processing the post after being saved:
I'll debug this case on Android in case the cause is different from iOS 🕵️ . |
I couldn't manage to reproduce the issue by following the same repro steps I used for iOS, however, I encountered local URLs by following the flow I commented on some time ago:
Steps:
EDIT: I tested this on the latest production version (18.1) and it's quite difficult to reproduce, I only managed to do it once following the exact same steps, so probably for Android we could consider this issue not a high priority. |
Hey @fluiddot 👋 I tried this quite a few times with different combinations but I couldn't reproduce. I tried on WPiOS's gallery-bug.MP4 |
Thanks @ceyhun for reviewing the PR ❤️ !
It can be a bit tricky to reproduce it because you have to close the post right after any of the uploads just finished. After watching the video you posted, I think you closed the post a bit sooner before an upload finishes to trigger the issue, if you waited a bit more I think you'll bump into it. I've tested it locally in a simulator with Metro connected and I managed to reproduce it, let me capture the steps I followed in the following video to help you reproducing it: Kapture.2021-09-17.at.11.39.23.mp4In the following screenshots, you can see the exact frames where I update the post and the editor closes, notice that two of the images are showing a placeholder at that moment that matches the
Let me know if you manage to reproduce it and if not, I'll be more than happy to set up a quick call to check it on live. |
Thanks @fluiddot 🙇 I was able to reproduce following these instructions 👍 |
Description
Some images point to local URLs (example:
//private/var/mobile/Containers/Data/Application/...
) when closing the post with ongoing uploads and re-opening when they're finished.Step-by-step reproduction instructions
This can be reproduced by following the "Close post with an ongoing image upload" test case:
Expected behaviour
The images' URL scheme should be
https://
.Actual behaviour
The images' URL scheme is
///
.Screenshots or screen recording (optional)
NOTE: This issue might be related to closing the post when the image is already uploaded but not loaded in the editor, as you can see in the screenshots, the first four items are showing a placeholder image right before the post is closed, and coincidentally these items are the ones that point to local URLs.
WordPress information
Device information
develop
The text was updated successfully, but these errors were encountered: