-
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
Media is not attached after relaunching the app #12060
Comments
@diegoreymendez After some more investigation, I found that there are 2 main problems here. They are the usage of full path URLs and using the cache directory. Problem A: Full Path URLsAfter we attach an image and we save the post, the content will look like this: <p>
<img
src="file:///var/mobile/Containers/Data/Application/92BED2B8-0498-41DF-BE0B-D0B24F3EAC9F/Library/Caches/Media/thumbnail-p3-2436x2436.jpeg"
class="size-full"
data-wp_upload_id="x-coredata://D5CF762D-7FB1-450D-B5A2-989DC0FC70B9/Media/p3"
>
</p> Notice that the
That UUID folder will change every time we run the app on Xcode. For example, when I run the app in Xcode again and create a new draft, the post content will look like this: <p>
<img
src="file:///var/mobile/Containers/Data/Application/6B2A2AF7-40B1-4ACB-BE59-A4D0095B288F/Library/Caches/Media/thumbnail-p4-2436x2436.jpeg"
class="size-full"
data-wp_upload_id="x-coredata://D5CF762D-7FB1-450D-B5A2-989DC0FC70B9/Media/p4"
>
</p> Notice that the Based on some light testing, it looks like this happens when the user upgrades the app from the App Store too. This does not happen when the user just force closes the app or the app crashes. ReferencesThese observations are corroborated by these references:
Possible SolutionIt looks like the right solution would be to not rely on the full path and use a relative path. For example, for this post content: <img
src="file:///var/mobile/Containers/Data/Application/6B2A2AF7-40B1-4ACB-BE59-A4D0095B288F/Library/Caches/Media/thumbnail-p4-2436x2436.jpeg"
> We will replace the <img src="file://Library/Caches/Media/thumbnail-p4-2436x2436.jpeg" > We will then convert this back to the full path when the post is reopened in the Editor. This will guarantee that we will be using the current application data path. This type of reference will survive across app upgrades. It does not stop here though. It looks like the Post List also relies on the full path to show the image by using WordPress-iOS/WordPress/Classes/Models/AbstractPost.m Lines 638 to 654 in 4b71c77
There might be more so we'll have to make adjustments to those places too. Problem B: Cache Directory UsageThe usage of
It looks like the Possible SolutionsUse a Persistent FolderIn the case of "thumbnails" generated for use in the Editor and Post List, I believe they shouldn't be in the
It looks like this can be done by changing the WordPress-iOS/WordPress/Classes/Services/MediaThumbnailService.swift Lines 45 to 47 in 4b71c77
I have not fully explored the repercussions of this. There might be other places that are using that method. On-the-fly GenerationAnother possible solution is if we can solve Problem A, we can try having an on-the-fly generation of the thumbnail. For example, I discussed above that the URL should be changed to this: <img src="file://Library/Caches/Media/thumbnail-p4-2436x2436.jpeg"> Since that is technically a placeholder now, we could insert additional data in there, like the <img src="file://Library/Caches/Media/thumbnail-p4-2436x2436.jpeg?mediaID=1234"> We can then use that Final ThoughtsI'll stop here for now until I hear your opinions. 🙂 I also have some questions for you to ponder:
@yaelirub and @jklausa, please let me know if you have any ideas too. |
Great research, @shiki! Is Problem B a current issue? How do you feel about splitting the ticket into an implementation for the relative paths (should probably be estimated between 3-5 imo) and a discussion ticket for the second issue that doesn't necessarily have to live in the offline support project board but instead maybe in Groundskeeping ? |
Thank you for responding, @yaelirub.
It is an issue but my guess is it's not likely to happen. It's probably okay to move it to the Groundskeeping backlog. |
Great! Let's create a new ticket for the relative path implementation and move it to the backlog with high priority. And another one for the cache usage to the backlog in Groundskeeping. I believe we can remove the 13 from this one and close #11846 once the relative path implementation is done Thank you, @shiki |
@shiki , any updates on this ^ ? |
@yaelirub Thanks for the nudge. It's been in my list of things to do. Since we're revisiting our list of issues to tackle though, do you think we should still work on this as part of Offline Posting or should we keep this as is and move everything to Groundskeeping? |
@shiki , I still stand by my previous suggestion:
|
Found in #11839 (comment) by @yaelirub.
Expected behavior
Media is attached to the post when the app is relaunched.
Actual behavior
The media upload resumes when the app was relaunched but the image was never attached to the post and only a placeholder is visible.
Steps to reproduce the behavior
This will be easier to reproduce if running the app from Xcode.
The text was updated successfully, but these errors were encountered: