-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Editor: images blink when upload is completed #21358
Comments
I also wonder why Gutenberg requires the media to have a |
Thanks for surfacing @kean! I've added it to one of our initiative issues related to media upload improvements and will un-assign myself from this for now.
I'm actually not entirely sure offhand. A guess would be that the picker passes the editor the image, the image gets uploaded to the backend, and then it's selectable (and configurable) once we know it exists on the site. |
After removing WPMediaPicker, this is now the last place that uses Simulator.Screen.Recording.-.iPhone.15.-.2023-11-27.at.16.37.42.mp4 |
I think this is less distracting than the blinkenlights effect we have today, but what happens when an upload fails? Does the user know which image they are retrying? |
It's inefficient in one more way: the high-resolution thumbnails are generated and saved twice during the upload. I've noticed it during my work on 23.2, but I think it's now the right time to address it.
As a result, the app ends up storing two high-resolution images on disk instead of just one. The resizing also puts extra pressure on the system, especially in terms of RAM usage. The high-resolution preview created during step 1 is used mainly in the Editor. Most of the other parts of the app use cc @fluiddot. |
Hmm, good point. I think there is a better way of addressing the performance issue (but not the blinking) by exposing the URLs for thumbnails managed by |
For reference, we have a similar GitHub issue in Gutenberg related to this: wordpress-mobile/gutenberg-mobile#6510 |
After some initial investigation from the editor side, I believe the blinking issue occurs within the Javascript editor code when the local media file ("thumbnail") is being replaced by the uploaded image from the server. The "blink" timespan may be the time spent downloading the new image from the server. On slower connections, it's more of a small nap than a blink.
As @fluiddot mentioned, we can work on improving the blink as part of wordpress-mobile/gutenberg-mobile#6510 by persisting the local media file until the server image is downloaded to create a seamless transition between the two states. If that were the case, we could probably bypass the image generated from While the performance improvements from the serving the image files are always welcome, the source of the blink itself probably doesn't require further investigation from the WPiOS side at the moment. |
Thanks @derekblank for investigating the issue 🙇 ! We could probably reproduce and confirm that the issue is related to waiting for the remote image download by throttling the network connection. Similarly, we could enforce a failure in the image download to check if the Image block results in a blank image.
Yep, we should only replace the local image with the remote one when it's fully downloaded. This will most likely address the blink issue. |
@kean I describe some of the details for the blink fix a bit further in Could we (or should we) be using |
Hey, @derekblank. I appreciate you fixing the issue with thumbnails!
The work for generating the thumbnails is not wasted. It uses Having said that, I would agree that the editor should not be using If you look at The only problematic part is the following, which I'm not sure what it does or why: case .thumbnailReady(let url) where ReachabilityUtils.isInternetReachable() && media.remoteStatus == .failed:
gutenberg.mediaUploadUpdate(id: mediaUploadID, state: .failed, progress: 0, url: url, serverID: nil)
case .thumbnailReady(let url) where !ReachabilityUtils.isInternetReachable() && media.remoteStatus == .failed:
// The progress value passed is ignored by the editor, allowing the UI to retain the last known progress before pausing
gutenberg.mediaUploadUpdate(id: mediaUploadID, state: .paused, progress: 0, url: url, serverID: nil)
case .thumbnailReady(let url):
gutenberg.mediaUploadUpdate(id: mediaUploadID, state: .uploading, progress: 0.20, url: url, serverID: nil)
break |
This code transmits the various media upload events that we send back to the Editor to listen for upload state: uploading, failed, retried, paused, etc. It seems very plausible that we could remove cc @dcalhoun |
While I do not completely understand the discussion regarding removing the synchronous thumbnail service or differences between The thumbnail events were expanded in #14140 and #17971 to improve error handling for various, nuanced error circumstances. Most recently, the events were expanded in #22282 to introduce a "paused" state that is utilized to display a different message when a media upload fails due to lack of an internet connection.
From my understanding, it is not incredibly clear to me whether we could remove the events. I'm uncertain as to what would replace its intended communication of "the upload failed, but here is a local thumbnail to display" to the editor. |
When the media is created, the observations.append(media.observe(\.localURL, options: [.new]) { [weak self] media, _ in
self?.didUpdateLocalThumbnail()
}) I don't think it's ideal that The
The part about the editor events is what I do not completely understand, but the availability of the thumbnail and the upload status updates should probably be independent events. |
In terms of what already exists and what needs to change, I think we all understand 2/3rds of the elements here, and just need to articulate our other third. We'll get there. 😅
I agree. This is what I was referencing in this comment:
My understanding is that these upload status events don't necessarily need to know that a generated thumbnail is available, but rather that a media upload has been initiated in general. If this understanding is correct, this may the the confusing part for you @kean -- the The confusing part for me is why these events were set to be dependent on |
It was fixed in one of the earlier versions, closing. |
When you add images to the post, and the upload completes, the images blink (shows blank canvas until they are downloaded):
Simulator.Screen.Recording.-.iPad.Air.5th.generation.-.2023-08-17.at.11.43.27.mp4
The text was updated successfully, but these errors were encountered: