signalapp / Signal-Android

A private messenger for Android.
https://signal.org
GNU Affero General Public License v3.0
25.72k stars 6.17k forks source link

crash on sharing video files not indexed by media scanner #3453

Closed sseide closed 6 years ago

sseide commented 9 years ago

whenever an intent to share video files is send to TextSecure, the app crashes (NullPointerException) sending the message to the recipient.

06-21 20:38:33.388    4959-4959/? W/ConversationActivity﹕ isManual Selection: false
06-21 20:38:33.388    4959-4959/? W/ConversationActivity﹕ forceSms: false
06-21 20:38:33.430    4959-5117/? W/dalvikvm﹕ threadid=17: thread exiting with uncaught exception (group=0x420299a8)
06-21 20:38:33.435    4959-5117/? E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:299)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
            at java.util.concurrent.FutureTask.run(FutureTask.java:239)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at java.lang.Thread.run(Thread.java:838)
     Caused by: java.lang.NullPointerException
            at java.lang.String.(String.java:228)
            at org.thoughtcrime.securesms.util.Util.toIsoString(Util.java:124)
            at org.thoughtcrime.securesms.mms.PartParser.getMessageText(PartParser.java:19)
            at org.thoughtcrime.securesms.database.MmsDatabase.insertMediaMessage(MmsDatabase.java:742)
            at org.thoughtcrime.securesms.database.MmsDatabase.insertMessageOutbox(MmsDatabase.java:724)
            at org.thoughtcrime.securesms.sms.MessageSender.send(MessageSender.java:102)
            at org.thoughtcrime.securesms.ConversationActivity$20.doInBackground(ConversationActivity.java:1130)
            at org.thoughtcrime.securesms.ConversationActivity$20.doInBackground(ConversationActivity.java:1127)
            at android.os.AsyncTask$2.call(AsyncTask.java:287)
            at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at java.lang.Thread.run(Thread.java:838)
06-21 20:38:33.445      609-620/? W/ActivityManager﹕ Force finishing activity org.thoughtcrime.securesms/.ConversationActivity

An similiar problem exists with audio files. They cannot be added, at least TextSecure does not crash here:

06-21 20:44:38.022    5323-5323/? W/ComposeMessageActivity﹕ java.io.IOException: Unable to query content type.
            at org.thoughtcrime.securesms.mms.AudioSlide.constructPartFromUri(AudioSlide.java:72)
            at org.thoughtcrime.securesms.mms.AudioSlide.(AudioSlide.java:37)
            at org.thoughtcrime.securesms.mms.AttachmentManager.setAudio(AttachmentManager.java:82)
            at org.thoughtcrime.securesms.ConversationActivity.addAttachmentAudio(ConversationActivity.java:893)
            at org.thoughtcrime.securesms.ConversationActivity.initializeDraft(ConversationActivity.java:632)
            at org.thoughtcrime.securesms.ConversationActivity.onCreate(ConversationActivity.java:190)
            at org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity.onCreate(PassphraseRequiredActionBarActivity.java:46)
            at android.app.Activity.performCreate(Activity.java:5122)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
            at android.app.ActivityThread.access$600(ActivityThread.java:156)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:153)
            at android.app.ActivityThread.main(ActivityThread.java:5299)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
            at dalvik.system.NativeStart.main(Native Method)
sseide commented 9 years ago

created pull request #3454 to fix this two issues

moxie0 commented 9 years ago

Thanks @sseide, please include either a full debug log or the version of TS and Android in bug reports.

rhodey commented 9 years ago

@sseide I'm unable to reproduce this when sharing audio and video from TS 2.18.0 tested on my gingerbread phone, and unable to reproduce this when sharing video from TS 2.19.0 tested on my Nexus 5 Lollipop device.

what apps did you use to share the audio and video with TextSecure?

rhodey commented 9 years ago

for reference, to test 2.18.0 on GB I used the default gallery app to share video with TS and the included file manager app to share the audio. to test 2.19.0 on Lollipop I used the new Google Photos app to share the video and had no apps installed that would allow me to share audio, lol music labels.

sseide commented 9 years ago

The default gallery app wont work. I believe the import thing here is the point that the audio or video file you want to share must not be indexed by the media scanner. And all pictures from the gallery are...

I discovered this crash when creating an new audio or video file at the sdcard and tried to share this via Android default Intent with the audio/video file name as EXTRA_STREAM.

Tested with last official version from store and master branch from git. Booth crash with an NPE on video files, no crash but error message that file cannot be attached on audio. Android Versions 4.2 and 4.4 testet.

To test for example "adb push" an video file onto the sdcard and send this file from an little helper app to textsecure with code like this:

private void sendIntent(File file) {
    Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setType("audio/*");
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
    getContext().startActivity(intent);
}

Files not indexed by the media scanner cannot be queried from the contentresolver (in AudioShare and VideoShare) but will be found with the code you already had used in the ShareActivity.

rhodey commented 9 years ago

@sseide thanks for the context, this makes sense to me now :)

automated-signal commented 6 years ago

GitHub Issue Cleanup: See #7598 for more information.