deckerst / aves

Aves is a gallery and metadata explorer app, built for Android with Flutter.
BSD 3-Clause "New" or "Revised" License
2.56k stars 96 forks source link

Thumbnail scanning stops on old avi file #61

Closed petazonk closed 3 years ago

petazonk commented 3 years ago

I have some old Canon avi files and when I click on the folder, or the entire collection, thumbnail generation stops when it hits the avi. No thumbnails are displayed from this point onwards and search stops working. If I click on the avi file it can play, but no sound comes through (not sure if that is important). At this point the only way to get Aves working is to force stop it and restart it. It then works normally until it tries to generate the thumbnail. 2006-06-24__15.15.47.avi.zip

deckerst commented 3 years ago

Thanks for the bug report. It's strange, fetching thumbnails should not impact other aspects like search...

I checked the AVI file on my device, and just like you say it's playable (without sound), but it didn't make the app hang or break searching.

Video thumbnails and video playing are handled in different ways, and sometimes Aves does not find a thumbnail even for playable files. In that case you get a thumbnail like this:

Which version of Aves are you using? Which Android version? Do you have a particularly large collection, or anything special like exotic image/video formats?

Also, if it's not already the case, would you mind enabling crash reporting in the privacy settings? It could be helpful if something is breaking in the background.

petazonk commented 3 years ago

Anonymous crash is enabled. It doesn't actually crash as I can still scroll but nothing new comes up.

I added about 16,000 photos which come from cameras from 2001 onwards which also included a few old videos (Canon IXUS). If I delete the old videos in question then it finishes displaying all the thumbnails (after a forced restart). I have a fully updated Pixel 3 which is on the latest version. The thumbnail in your screenshot is what I get, but also any other jpg after the video is not displayed and I just get the black/gray squares.

petazonk commented 3 years ago

Something interesting is going on. So, I tried again to reproduce the bug by saving the video from email to /downloads. Couldn't reproduce as you said. Copied the video from Windows 10, over USB, to phone and couldn't reproduce. Made 10 copies of the the video and copied over USB to the phone and then reproduced the bug (while the phone was still plugged into Windows

So, I copied all the videos back on again and could reproduce the problem again. If I scroll really fast to the bottom there are lots of missing thumbnails from the start to the end. If I scroll down slowly and allow the thumbnails to load, then the problem only hits when I get to videos from Jun 2006.

On Thu, 2 Sept 2021 at 13:45, Peter @.***> wrote:

Anonymous crash is enabled. It doesn't actually crash as I can still scroll but nothing new comes up.

I added about 16,000 photos which come from cameras from 2001 onwards which also included a few old videos (Canon IXUS). If I delete the old videos in question then it finishes displaying all the thumbnails (after a forced restart). I have a fully updated Pixel 3 which is on the latest version. The thumbnail in your screenshot is what I get, but also any other jpg after the video is not displayed and I just get the black/gray squares.

petazonk commented 3 years ago

Here is a screenshot.

On Thu, Sep 2, 2021, 2:55 PM Peter @.***> wrote:

Something interesting is going on. So, I tried again to reproduce the bug by saving the video from email to /downloads. Couldn't reproduce as you said. Copied the video from Windows 10, over USB, to phone and couldn't reproduce. Made 10 copies of the the video and copied over USB to the phone and then reproduced the bug (while the phone was still plugged into Windows

  • not sure if that matters) .

So, I copied all the videos back on again and could reproduce the problem again. If I scroll really fast to the bottom there are lots of missing thumbnails from the start to the end. If I scroll down slowly and allow the thumbnails to load, then the problem only hits when I get to videos from Jun 2006.

On Thu, 2 Sept 2021 at 13:45, Peter @.***> wrote:

Anonymous crash is enabled. It doesn't actually crash as I can still scroll but nothing new comes up.

I added about 16,000 photos which come from cameras from 2001 onwards which also included a few old videos (Canon IXUS). If I delete the old videos in question then it finishes displaying all the thumbnails (after a forced restart). I have a fully updated Pixel 3 which is on the latest version. The thumbnail in your screenshot is what I get, but also any other jpg after the video is not displayed and I just get the black/gray squares.

deckerst commented 3 years ago

Curiouser and curiouser! Thanks for taking the time to do all these tests. I don't understand yet what's causing the issue but I'll try and figure it out.

Didn't you forget the screenshot in your last comment?

petazonk commented 3 years ago

It's definitely something to do with videos however the Pixel videos load fine and some of them are up to 500mb in size. Once I delete all the really old Canon videos it works fine. It never crashes but instead stops loading thumbnails.

On Thu, Sep 2, 2021, 4:14 PM Thibault Deckers @.***> wrote:

Curiouser and curiouser! Thanks for taking the time to do all these tests. I don't understand yet what's causing the issue but I'll try and figure it out.

Didn't you forget the screenshot in your last comment?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/deckerst/aves/issues/61#issuecomment-911241951, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVNKTEMN7XS75QC6PXRILELT74I3DANCNFSM5DDJODPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

petazonk commented 3 years ago

Looks like the screenshots don't get attached here when sent in by email.

petazonk commented 3 years ago

I think I have found the problem specifically. Make 4 copies of the video above onto your phone. Then in the app, select videos and you should see the 4 grayed out thumbnails. Cancel the Video search or go back to all content, now, any cached thumbnails will not load. A forced restart will fix the problem until you try and load the video thumbnails again. This is a 100% reproducible on my Pixel 3 phone that is fully updated. Lastly, if I delete just one video it will work fine, but if I copy and paste the video so that I have four copies it will again produce the bug.

deckerst commented 3 years ago

Thanks for helping with the investigation. I tried to reproduce, following your instructions:

  1. getting 4 copies of the videos on my device (Samsung S10e, Android 11)

  2. launching the app (my Home is the full Collection)

  3. via the navigation menu, I select "Videos", I see this:

  4. then I remove the "Video" filter by tapping on the "X"

  5. I scroll down my collection, and the thumbnails load as expected

Would you be able to take a video capture of what you just described? (You can privately send it to me.)

Unrelated: I added support for the audio used in these old videos, so you can play them with sound in the next release of Aves.

petazonk commented 3 years ago

Maybe it is RAM related as the Pixel3 only has 4GB? Maybe try making 16 copies of the video? Will message you some screenshots.

petazonk commented 3 years ago

Here is one screenshot, how can I message you for another one? Aves_all_sshot-2021-09-06-141014

deckerst commented 3 years ago

One thing that looks strange to me in your screenshots (beyond the grey thumbnails) is the app bar subtitle "Cataloguing" should never appear without the progress next to it. Normally it looks like this: Screenshot_20210906-181747_Aves  Profile

On app launch, the normal sequence of app bar subtitle is: 1) "loading" (lasts ~1 second for 10k items) 2) "cataloguing X/Y", for all the newly discovered items. It can take a while, but the process can safely be stopped when closing the app, and resumed later. 3) "locating" (without progress) while it loads a topojson file for quick reverse geocoding of new items 4) "locating X/Y" for fine reverse geocoding of new items. This can take a long time, but again it's safe to close and reopen the app later.

When the app is opened and there are no new pictures or videos, there's just the "loading" phase and that's it.

If you open the app and you don't try to scroll through the problematic videos, does the app succeed in cataloguing everything?

petazonk commented 3 years ago

Yes that happens when the problem occurs. That is why I got that in the screenshot.

It goes through the normal process as long as I don't get to the bad videos.

On Mon, Sep 6, 2021, 7:36 PM Thibault Deckers @.***> wrote:

One thing that looks strange to me in your screenshots (beyond the grey thumbnails) is the app bar subtitle "Cataloguing" should never appear without the progress next to it. Normally it looks like this: [image: Screenshot_20210906-181747_Aves Profile] https://user-images.githubusercontent.com/13898333/132193361-d40b889b-3c4b-4a3a-80a9-4d25bf36541b.png

On app launch, the normal sequence of app bar subtitle is:

  1. "loading" (lasts ~1 second for 10k items)
  2. "cataloguing X/Y", for all the newly discovered items. It can take a while, but the process can safely be stopped when closing the app, and resumed later.
  3. "locating" (without progress) while it loads a topojson file for quick reverse geocoding of new items
  4. "locating X/Y" for fine reverse geocoding of new items. This can take a long time, but again it's safe to close and reopen the app later.

When the app is opened and there are no new pictures or videos, there's just the "loading" phase and that's it.

If you open the app and you don't try to scroll through the problematic videos, does the app succeed in cataloguing everything?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/deckerst/aves/issues/61#issuecomment-913501827, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVNKTENVUENFEJ4ALA3IZ3LUASDSHANCNFSM5DDJODPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

petazonk commented 3 years ago

I just reproduced the problem on my wife's Pixel 4XL as well. I emailed her the video and copied it multiple times.

On Mon, Sep 6, 2021, 7:43 PM Peter @.***> wrote:

Yes that happens when the problem occurs. That is why I got that in the screenshot.

It goes through the normal process as long as I don't get to the bad videos.

On Mon, Sep 6, 2021, 7:36 PM Thibault Deckers @.***> wrote:

One thing that looks strange to me in your screenshots (beyond the grey thumbnails) is the app bar subtitle "Cataloguing" should never appear without the progress next to it. Normally it looks like this: [image: Screenshot_20210906-181747_Aves Profile] https://user-images.githubusercontent.com/13898333/132193361-d40b889b-3c4b-4a3a-80a9-4d25bf36541b.png

On app launch, the normal sequence of app bar subtitle is:

  1. "loading" (lasts ~1 second for 10k items)
  2. "cataloguing X/Y", for all the newly discovered items. It can take a while, but the process can safely be stopped when closing the app, and resumed later.
  3. "locating" (without progress) while it loads a topojson file for quick reverse geocoding of new items
  4. "locating X/Y" for fine reverse geocoding of new items. This can take a long time, but again it's safe to close and reopen the app later.

When the app is opened and there are no new pictures or videos, there's just the "loading" phase and that's it.

If you open the app and you don't try to scroll through the problematic videos, does the app succeed in cataloguing everything?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/deckerst/aves/issues/61#issuecomment-913501827, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVNKTENVUENFEJ4ALA3IZ3LUASDSHANCNFSM5DDJODPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

deckerst commented 3 years ago

As a reminder for my future self, here's an explanation.

When fetching video thumbnails, the Flutter side communicates with the Android platform side. On the platform side, a custom Glide module is used to fetch the thumbnail using the native MediaMetadataRetriever. The Glide module absolutely needs to report back a success or a failure, otherwise it will wait forever. But for some video formats (e.g. AVI with specific codecs), the MediaMetadataRetriever fails to fetch thumbnails and it fails in different ways depending on the device. On a Samsung phone, it initializes fine but fails when fetching the thumbnail, while on a Pixel device it fails during initialization. The custom Glide module was properly reporting the failure in the first case, but not the second one, so it was waiting forever for the video thumbnail.

And the app starts to globally fail when 4 copies of the problematic video is encountered because operations requiring work on the platform side (thumbnail fetch, cataloguing, and many more) are pooled and parallelized up to 4 concurrent tasks. If these 4 concurrent tasks hang and never complete, no more platform side task can start.