bepaald / signalbackup-tools

Tool to work with Signal Backup files.
GNU General Public License v3.0
790 stars 38 forks source link

Imported audio messages won't play/crash Signal #77

Closed wearepariah closed 2 years ago

wearepariah commented 2 years ago

When trying to play audio messages imported from an SMS/MMS XML backup (using https://github.com/wearepariah/sms-mms-import-to-signal), they crash the Signal app. These audio messages play fine on the PC, and when launced from the exported Signal backup. All the audio messages from the 'Signal era' (received after switching to Signal) continue to play within the app without issue. Some comments I found on other issues seem to indicate that this has happened with merged Signal backups as well?

bepaald commented 2 years ago

Hi. That's an interesting project, I didn't know it existed, I'll check it out! I'm pretty curious how it works, because I haven't completely figured out how to add attachments to the database (changing existing attachments is easy, as is adding text-only messages). There are some fields in the part database which are required, but I don't know what data to fill them with exactly (this might actually be the cause of the problem you are encountering).

As for the merging bug, it was a while ago (here: https://github.com/bepaald/signalbackup-tools/issues/27#issuecomment-789256441). I was never able to reproduce the problem myself, but did make some changes that may have been related (again, see #27). I have never had a reply that states explicitly that the problem was fixed. But I have had no more reports on it, and whenever I asked anyone, they reported no problems (for example, see the last messages in #38). Note however, that this problem - if it still exists at all - would not cause Signal to crash: the audio would simply refuse to play, but the app remained running normally.

I strongly believe this is bug report does not belong here, but in your own project (and/or the original project it was forked from). And if I had to guess, it probably has to do with empty fields in the part-table. But I would certainly like to investigate this when I have some time. Do you have any small xml example I could use to reproduce this issue? No providers have support for mms since years ago in my country, so I can not easily create one myself. Also, while Signal crashing is of course a bigger problem than simply not playing the audio, I think it does mean you can get a lot more useful info from adb logcat. I suggest you look into that.

wearepariah commented 2 years ago

Hi, I have done a bit more testing, it's also trying to view the info on any imported MMS message that causes the app to crash. Noting that, i had a look at some examples in the part-table, and am inclined to agree that the issue is with the import and belongs over on my own project. I found one field pending_push that I had left null which is normally a 0 (testing now whether this fixes it), and three others _data, data_random, data_hash I had left null which are not 'normally'.

I will explore what adb logcat tells me, and see what I can do about grabbing out a small XML snippet of some MMS to share.

wearepariah commented 2 years ago

Small update, I have loaded my SMS/MMS in to a backup, loaded the backup to Signal, re-backed it up and extracted it again, and found that _data & data_random are now populated on the MMS that I have imported, it is only the data_hash field mentioned above that is now null but isn't normally. Here is a sample of a single MMS audio message for you to play with as well. sample_mms.zip

wearepariah commented 2 years ago

Can confirm, setting the pending_push value to 0 at the insert to the part-table has made playing the audio no longer crash the app. Things work, thank you! My project wouldn't have been possible without all of your work here, thank you!

bepaald commented 2 years ago

Excellent, glad you solved it so quickly.

Just a bit of info: the data_hash field is simply the sha256 sum of the attachment data. I do set it when editing attachments just for the sake of completeness (here) and because of the encryption and decryption all the required libraries are already included anyway. But I have some backups going back to 2016, and can inform you that up until November 2019, the data_hash field is empty. So, it should not be necessary to fill it, since Signal must be able to deal with empty hash field to keep old messages working.

Anyway - again - happy your problem is solved. If you ever run into something again, feel free to open a new issue, time permitting I might be able to help.

Cheers!