Wrong file suffix on saving videos
I just received a video within a group chat in Signal 3.4.0. When I save that video, it is saved to sdcard\Movies\textsecure-2015-11-14-131819.attach
To make it play in other apps I have to open a file manager and rename the video to textsecure-2015-11-14-131819.mp4
I would expect Signal to directly save the file as textsecure-2015-11-14-131819.mp4
I would expect Signal to directly save the file as textsecure-2015-11-14-131819.mp4
Even better would be "signal-2015-11-14-131819.mp4"... :smile:
...or the original file name of the senders file ;)
This happens only when the file does not report a mimetype, so the video file didnt state it was an mp4 thus signal chose the default .attach as the extension.
That's not true:
$ file --mime-type -b textsecure-2015-11-14-131819.attach
video/mp4
Hey @mcginty i would like to give this a shot ive looked over the code and there is a check to see if the mimetype ==null and then it sets that attachment but that is not where it goes awry. I would love some tips on where to look
@rmueller83 could you upload the video file somewhere? this would make it easier to debug...
...or the original file name of the senders file ;)
@rmueller83 Using the sender's original file name could be a privacy issue, though. Same holds true for some embedded Exif metadata like GPS coordinates. Is this stuff stripped off before sending? No idea.
Sorry, I cannot share the video as it contains personal content. I tried everything to reproduce the problem locally, using the original file + file name and sending it from the emulator to my phone, but without success yet. Btw, the problem is not related to group chats. If I am correct the content type is set by the sender and contained in the message. So I suspect the error is happening on the sender side...
was it recorded by the sender? If yes, could you maybe ask the sender to record another video and upload it somewhere?
The sender just sent me the mp4 sample video (3rd download) from this page: https://support.apple.com/en-us/HT201549 And I also received it with .attach suffix. He is using Signal 3.3.3 on Android 5.0.1, but I could not reproduce this in the emulator using the same versions. :-1:
I cant reproduce it :smirk:
Maybe its his device? What device is he using?
He is using a Moto G 2nd Gen with Android 5.0.2, I have a Moto G 1st Gen with Android 5.1. Perhaps @bartz1 (from #4560) could also try the video and post his specs?
Regarding the information of the mime type, I think it is important to look at the results from the Android framework. See the referenced issue above.
This is an interesting finding, but it seems that the mentioned method is only called on the receiver side when the attachment is saved. So the saving of a certain mime type would always or never work, which is not the case. I think the misbehavior is due to the value of the contentType argument whose value seems to come from the sender.
@rmueller83 Yes, this is called on the receiver. But as mentioned there, some manufactures modify this map, so maybe this adds to the difficulty of reproducing: depends on sender/receiver pair.
By skimming the code, it seems that the value of the contentType could possibly come from this mapping as well.
@rmueller83 , any chance you can attach a debugger, set a breakpoint on the following line, and try saving the problem video to see the value of contentType?
SaveAttachmentTask.java, line 124, master HEAD (493bd9b)
if (extension == null)
I just tried this via USB, but Android Studio only shows "No Debuggable Applications". :-(
Good news: I managed to let him send the sample video to my Signal instance running in the emulator. I cannot see the contentType and extension variables in the variables window (do I need to use a different way of building?) but if I step one line further, the debugger goes into line 125 (extension = "attach";) instead of skipping it.

Ah, you can temporarily add -dontobfuscate to proguard.cfg and rebuild. That will let you inspect local variables. Someone else will probably chime in with a better way, though. :grin:
Thanks for the followup!
Thanks, that works. Now I can see that contentType = "video/*" which leads to extension = null. It should be contentType = "video/mp4".