signalapp / Signal-Android

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

Signal crashes few seconds after Launch. Cause corrupted signal-jobmanager.db #13762

Open tnixeu opened 3 weeks ago

tnixeu commented 3 weeks ago

Guidelines

Bug description

Since a recent Signal update, probably 7.17.4, Signal Crashes a few seconds after launch. Currently the phone runs 7.21.5. I have uploaded a log already in #13697, which shows that the signal-jobmanager.db is corrupted. I have uploaded the log again here: log.txt. I am starting a new issue since is was stated that this is unrelated the bug in that issue.

Signal at first seems to start fine. It loads the full GUI and shows all recently received messages, even those received after Signals started crashing. However, few seconds later it crashes. New messages are also shown in the notifications bar, however, replying or "Mark as read" do not work. I was able to connect Signal to a PC, by being fast.

This leads me to believe that the database containing my messages is not affected. In #12435 it was stated, that the signal-jobmanager.db is used for pending message, which I now interpret as pending outgoing messages. As root it can be deleted, however, I am not root on this device.

I am looking for a way to fix the issue by deleting or recreating the affected database.

Screenshots

No response

Device

Samsung S7

Android version

8

Signal version

7.21.5

Link to debug log

https://github.com/user-attachments/files/17598807/log.txt

rishabh-bhatia commented 2 weeks ago

Hi there, sorry if this sounds obvious but have you tried to clear the cache? The logs seem to indicate that the issue is related to Encryption key/DB corruption. Clearing cache seems to be the only way you can safely force the app to reset tables without losing data. If you're looking to wipe signal-jobmanager.db without root access, you should be able to do that by modifying the code and compiling your own version of the app( If no official support is provided).

tnixeu commented 2 weeks ago

I have tried clearing the cache, however, it did not help. I just tired again.

I haven't tired something like this yet, because I think Android protectes against that.

rishabh-bhatia commented 2 weeks ago

Hey @greyson-signal is this a common occurrence? If so it could be affecting the UX on a larger scale. Quoting you from #12435 .

This is one of those cases where it's probably fine to delete it, but in general not-fine. It stores state about pending messages and such, and it could throw things out of whack.

Implies that in general we don't expect signal-jobmanager.db to be corrupted. So in the rare case where it does get corrupted, wouldn't it be a better option to delete it rather than getting the user to clear storage and lose all chats?

From what I could tell by looking at the code briefly, deleting this DB would not be "ideal"(Especially if it is deleted too often). However, in the rare case it does get corrupted then it needs to be deleted to protect everything else. In case signal-jobmanager.db is getting corrupted too often then this could indicate another bug.

greyson-signal commented 4 days ago

It's definitely not great to lose that data, but I think you're right that it might be better here to reset that table. I'll make that change.

rishabh-bhatia commented 4 days ago

Apologies for the direct PR. I spent some time on this issue sometime back and figured this might be a decent fix. Just added a couple of tests to my version of the fix i.e. delete the signal-jobmanager.db when corruption is detected through onCorruption. Corrupting the DB manually was not triggering a call to onCorruption in the error handlers which meant that the only way to verify that the solution works was by adding some Unit tests. Please feel free to take this change or propose any improvements whatsoever and I'll try to get back to you as soon as Possible.