wordpress-mobile / WordPress-Android

WordPress for Android
http://android.wordpress.org
GNU General Public License v2.0
2.97k stars 1.32k forks source link

Media Gallery Has No Video Thumbnails #15871

Open mchowning opened 2 years ago

mchowning commented 2 years ago

Expected behavior

The Media Gallery displays video thumbnails.

Actual behavior

The Media Gallery displays gray placeholders for all videos. Clicking on a video brings up the detail screen and displays a "Media Thumbnail could not be loaded" message. The network inspector shows a bunch of 403 unauthorized errors trying to fetch the thumbnails.

If I use the media picker from the editor, I do see many of the video thumbnails (not all of them, but I think that's due to the video size as discussed in https://github.com/wordpress-mobile/WordPress-Android/issues/15443).

Also, the previews loaded as expected on WPiOS 19.1.0.20220124.

Steps to reproduce the behavior

  1. Log into an account with videos in the media library.
  2. Tab the Media Button
  3. Tap the Videos tab
  4. Observe no thumbnails are shown
  5. Tap on one of the videos
  6. Note that the detail screen does not show the video's thumbnail and there is a toast saying "Media Thumbnail could not be loaded"

https://user-images.githubusercontent.com/4656348/151605610-d43ff5f3-8d78-4224-917c-17485ed6e7fe.mp4

Tested on Pixel 6 Pro and Pixel 3, Android 12, WPAndroid alpha-339 (1159)
mchowning commented 2 years ago

👋 @ashiagr ! I know you've done some work with the media picker, so checking in case this rings any bells for you.

ashiagr commented 2 years ago

Hey @mchowning! 👋

I can see video thumbnails in the Media Gallery. Is it possible for you to invite me to the site where you're seeing the issue? Also copying @ravishanker, who's currently working on the media-related issues to know if it is a known issue.

https://user-images.githubusercontent.com/1405144/151776023-ba14a965-a21d-4f7c-9cee-1817272c43cb.mp4

Tested on Pixel 5, Android 12, WPAndroid alpha-339 (1159)
mchowning commented 2 years ago

Thanks for testing @ashiagr ! That's interesting that it works for you. That made me wonder if there might be something up with my physical devices, so I also tested this on two just-created Pixel 4 emulators (API 31 and API 28 respectively) and saw the missing thumbnails on both those devices too. Now I'm starting to wonder if there could be something up with my account. 🤔

Is it possible for you to invite me to the site where you're seeing the issue?

In addition to my test site (shown in the video above) I also don't see thumbnails for mobilegutenberg.wordpress.com, appsp2.wordpress.com, and wpmobilep2.wordpress.com (to this point, there haven't been thumbnails for me on any site I've tested).

ashiagr commented 2 years ago

I can reproduce the issue on appsp2.wordpress.com, wpmobilep2.wordpress.com having below properties:

jetpack:false
jetpack_connection:false
is_multisite:true
is_private:true

But I can see video thumbnails on simple, atomic, and jetpack-connected sites. I'll continue to investigate and share my findings.

ashiagr commented 2 years ago

So I narrowed down this issue to be occurring only on private sites.

If I use the media picker from the editor, I do see many of the video thumbnails (not all of them, but I think that's due to the video size as discussed in https://github.com/wordpress-mobile/WordPress-Android/issues/15443).

It seems that the media picker from the editor uses video url and loads thumbnail from it.

However, the media gallery first checks if the media has a thumbnail, it loads from it, otherwise loads the thumbnail from the video path or URL.

Looking at the 403 error code, it seems like authorization headers might not be correctly set when requesting video thumbnails for private sites. But I verified that authorization headers are added to all Glide requests, so I'm quite unsure what's happening here.

As a workaround, we can skip loading video thumbnails from thumbnail URLs for private sites in the media gallery and load them from the video path or URL just like the media picker from the editor. I tested it and could see thumbnails loading from it.

@ravishanker, it seems you're currently looking into media-related issues (please correct me if you're not 😅), let me know what you think of it or if you have any suggestions for this issue.

EDIT: Here's a branch with the workaround if anyone wants to test.