mattermost / mattermost

Mattermost is an open source platform for secure collaboration across the entire software development lifecycle..
https://mattermost.com
Other
28.69k stars 7.03k forks source link

RN: Confirm video saving in gallery #25559

Open mattermod opened 7 months ago

mattermod commented 7 months ago

From the investigation in https://mattermost.atlassian.net/browse/MM-52952

Seems like saving video or other files (application/octet-stream or application/postscript also appear in the logs) may save to the wrong folder on Android. Investigate the root cause and fix. May be in app/screens/gallery/footer/download_with_action/index.tsx when doing saveImageOrVideo.


If you're interested please comment here and come join our "Contributors" community channel on our daily build server, where you can discuss questions with community members and the Mattermost core team. For technical advice or questions, please join our "Developers" community channel.

New contributors please see our Developer's Guide.

JIRA: https://mattermost.atlassian.net/browse/MM-53336

tanmaythole commented 7 months ago

Hi @larkox, I want to pick this. Can you please assign it to me?

larkox commented 7 months ago

Thank you @tanmaythole ! Keep in mind it requires some investigation to properly find the cases where this happen, and how to fix it.

tanmaythole commented 7 months ago

Sure @larkox , Could you please assist me in identifying the expected locations where images and videos are saved?

larkox commented 7 months ago

@tanmaythole If the problem is where I expect it (where it is mentioned in the description), it is mainly when we save a image / document / anything from the gallery view. But I am not 100% sure.

tanmaythole commented 7 months ago

Hi @larkox ,

I have investigated some scenarios and found the following:

  1. When I save a video from the footer of the GalleryView, it calls the function saveImageOrVideo.
  2. When I save videos from the bottom sheet options of ChannelFiles, it calls the function saveFile.

This occurs because the type for video is set as file in /app/components/files_search/file_options/toasts.tsx:20 for ChannelFiles, while for GalleryView, it is set as video. Consequently, this leads to different function calls and results in variations in the download location.

As per my understanding, video files always trigger the saveImageOrVideo function for download. Please correct me if I'm wrong.

larkox commented 7 months ago

In theory that is what should happen. Nevertheless, this is what we see in the reports from Google Play:

com.reactnativecommunity.cameraroll.CameraRollModule$SaveToCameraRoll.doInBackgroundGuarded

Stack trace:

Exception java.lang.RuntimeException: An error occurred while executing doInBackground()
  at android.os.AsyncTask$4.done (AsyncTask.java:415)
  at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:381)
  at java.util.concurrent.FutureTask.setException (FutureTask.java:250)
  at java.util.concurrent.FutureTask.run (FutureTask.java:269)
  at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:644)
  at java.lang.Thread.run (Thread.java:1012)
Caused by java.lang.IllegalArgumentException: MIME type application/octet-stream cannot be inserted into content://media/external/images/media; expected MIME type under image/*
  at android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:172)
  at android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:142)
  at android.content.ContentProviderProxy.insert (ContentProviderNative.java:557)
  at android.content.ContentResolver.insert (ContentResolver.java:2196)
  at android.content.ContentResolver.insert (ContentResolver.java:2157)
  at com.reactnativecommunity.cameraroll.CameraRollModule$SaveToCameraRoll.doInBackgroundGuarded (CameraRollModule.java:169)
  at com.reactnativecommunity.cameraroll.CameraRollModule$SaveToCameraRoll.doInBackgroundGuarded (CameraRollModule.java:128)
  at com.facebook.react.bridge.GuardedAsyncTask.doInBackground (GuardedAsyncTask.java:35)
  at com.facebook.react.bridge.GuardedAsyncTask.doInBackground (GuardedAsyncTask.java:19)
  at android.os.AsyncTask$3.call (AsyncTask.java:394)
  at java.util.concurrent.FutureTask.run (FutureTask.java:264)

Another possibility is that we and the camera roll are looking for the mime type in different places, and there are things getting through when they shouldn't.

Thoughts?