oxen-io / session-ios

A private messenger for iOS.
https://getsession.org
GNU General Public License v3.0
386 stars 85 forks source link

Migration error when I try to test changes on devices #945

Open MiguelSernaMon opened 6 months ago

MiguelSernaMon commented 6 months ago

Code of conduct

Self-training on how to write a bug report

Is there an existing issue for this?

Current Behavior

When I install Session I get a migration error even if I use the official IPA.
It seems like the StartupError function is always executing, even in the simulators of xcode I saw this problem a few times but the restore button works. Here is the log: 2024/01/02 21:07:21:826 💛 [AppDelegate.swift:125 application(:didFinishLaunchingWithOptions:)]: application: didFinishLaunchingWithOptions completed. 2024/01/02 21:07:21:836 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:21:837 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:21:840 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:21:841 💛 2024/01/02 21:07:21:843 💛 [Session] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:07:21:845 💛 [Session, Main] Showing startup alert due to error: Database error 2024/01/02 21:07:24:160 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:24:162 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:24:164 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:24:165 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:24:167 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:24:168 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:24:169 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:24:172 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:24:186 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:24:191 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:24:192 💛 [Session, Main] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:07:24:195 💛 [Session, Main] Showing startup alert due to error: Failed to restore 2024/01/02 21:07:32:038 💛 [AppDelegate.swift:125 application(:didFinishLaunchingWithOptions:)]: application: didFinishLaunchingWithOptions completed. 2024/01/02 21:07:32:052 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:32:053 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:32:054 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:32:056 💛 [Session] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:07:32:057 💛 [Session, Main] Showing startup alert due to error: Database error 2024/01/02 21:07:32:297 💛 2024/01/02 21:07:47:856 💛 [Version] iOS 15.4.1, App: 2.4.4 (428), libSession: v1.1.0-nogit 2024/01/02 21:07:50:316 💛 [Session, Main] Showing startup alert due to error: Database error 2024/01/02 21:07:51:926 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:51:928 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:51:930 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:51:931 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:51:938 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:51:939 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:51:940 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:51:942 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:51:943 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:51:975 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:07:51:976 💛 [Session, Main] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:07:51:979 💛 [Session, Main] Showing startup alert due to error: Failed to restore 2024/01/02 21:08:20:487 💛 [AppDelegate.swift:125 application(:didFinishLaunchingWithOptions:)]: application: didFinishLaunchingWithOptions completed. 2024/01/02 21:08:20:503 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:08:20:504 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:08:20:506 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:08:20:507 💛 [Session] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:08:20:508 💛 [Session, Main] Showing startup alert due to error: Database error 2024/01/02 21:08:20:748 💛 2024/01/02 21:09:43:001 💛 [AppDelegate.swift:125 application(:didFinishLaunchingWithOptions:)]: application: didFinishLaunchingWithOptions completed. 2024/01/02 21:09:43:019 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:43:020 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:43:022 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:43:023 💛 [Session] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:09:43:025 💛 [Session, Main] Showing startup alert due to error: Database error 2024/01/02 21:09:43:245 💛 2024/01/02 21:09:56:070 💛 [AppDelegate.swift:125 application(:didFinishLaunchingWithOptions:)]: application: didFinishLaunchingWithOptions completed. 2024/01/02 21:09:56:088 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:56:089 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:56:090 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:56:091 💛 [Session] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:09:56:093 💛 [Session, Main] Showing startup alert due to error: Database error 2024/01/02 21:09:56:330 💛 2024/01/02 21:09:57:314 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:57:317 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:57:319 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:57:320 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:57:325 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:57:326 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:57:327 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:57:330 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:57:331 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:57:346 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:09:57:347 💛 [Session, Main] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:09:57:350 💛 [Session, Main] Showing startup alert due to error: Failed to restore 2024/01/02 21:10:02:848 💛 [AppDelegate.swift:125 application(:didFinishLaunchingWithOptions:)]: application: didFinishLaunchingWithOptions completed. 2024/01/02 21:10:02:866 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:02:867 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:02:868 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:02:869 💛 [Session] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:10:02:871 💛 [Session, Main] Showing startup alert due to error: Database error 2024/01/02 21:10:03:094 💛 2024/01/02 21:10:04:250 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:04:253 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:04:254 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:04:256 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:04:261 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:04:262 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:04:263 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:04:265 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:04:266 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:04:275 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:04:276 💛 [Session, Main] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:10:04:279 💛 [Session, Main] Showing startup alert due to error: Failed to restore 2024/01/02 21:10:07:613 💛 [AppDelegate.swift:125 application(:didFinishLaunchingWithOptions:)]: application: didFinishLaunchingWithOptions completed. 2024/01/02 21:10:07:632 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:07:633 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:07:635 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:10:07:636 💛 [Session] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:10:07:637 💛 [Session, Main] Showing startup alert due to error: Database error 2024/01/02 21:10:07:870 💛 2024/01/02 21:13:39:322 💛 2024/01/02 21:13:40:302 💛 [Session, Main] Entered background before startup was completed 2024/01/02 21:13:40:311 💛 2024/01/02 21:13:40:315 💛 2024/01/02 21:15:44:113 💛 [AppDelegate.swift:125 application(:didFinishLaunchingWithOptions:)]: application: didFinishLaunchingWithOptions completed. 2024/01/02 21:15:44:125 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:15:44:126 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:15:44:131 ❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed. 2024/01/02 21:15:44:132 💛 [Session] [Database Error] Statup failed with error: SQLite error 14: unable to open database file 2024/01/02 21:15:44:133 💛 [Session, Main] Showing startup alert due to error: Database error 2024/01/02 21:15:44:317 💛 2024/01/02 21:15:45:261 💛 2024/01/02 21:15:46:142 💛 [Session, Main] Entered background before startup was completed 2024/01/02 21:15:46:145 💛 2024/01/02 22:25:03:239 💛 [ScreenLockUI.swift:363 clockDidChange()]: clock did change 2024/01/02 22:25:03:242 💛 2024/01/02 22:25:03:560 💛 2024/01/02 22:25:04:757 💛 [Version] iOS 15.4.1, App: 2.4.4 (428), libSession: v1.1.0-nogit

Expected Behavior

The app should open without problem

Steps To Reproduce

  1. Download the official IPA from GitHub
  2. install it on your iPhone using sideloadly
  3. open the app

iOS Version

iOS 15.4

Session Version

2.4.4

Anything else?

image

mpretty-cyro commented 6 months ago

So in these logs it looks like for some reason the app can't access the "shared data directory"

❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed.

The "shared data directory" is an "AppGroup" directory (basically a directory which can be accessed by the app, share & notification extensions), these directories need to be registered with Apple and built into the app when compiling (In the source it can be found in the Session target -> Signing & Capabilities -> App Groups, as well as in SNUserDefaults.swift L:65) currently it's hard-coded to group.com.loki-project.loki-messenger

@MiguelSernaMon I've not used Sideloadly before, do you know if it supports App Groups?

If it does then we'd also need to make a change to the code to detect that it's been side-loaded and request the custom AppGroup identifier on the first launch so that we can load the database from the correct location 🤔

MiguelSernaMon commented 6 months ago

So in these logs it looks like for some reason the app can't access the "shared data directory"

❤️ [MainAppContext.swift:238 appSharedDataDirectoryPath()]: Assertion failed.

The "shared data directory" is an "AppGroup" directory (basically a directory which can be accessed by the app, share & notification extensions), these directories need to be registered with Apple and built into the app when compiling (In the source it can be found in the Session target -> Signing & Capabilities -> App Groups, as well as in SNUserDefaults.swift L:65) currently it's hard-coded to group.com.loki-project.loki-messenger

@MiguelSernaMon I've not used Sideloadly before, do you know if it supports App Groups?

If it does then we'd also need to make a change to the code to detect that it's been side-loaded and request the custom AppGroup identifier on the first launch so that we can load the database from the correct location 🤔

I've been trying several sideload apps like Scarlet, altstore, and Impactor. None of them work. The only one that works for me was Trollstore (it uses exploits to install and sign apps forever) but I don't know why session works with this method.

In general, I think that the problem may be that when Session is sideloaded the shared data directory can't be accessed correctly with the actual code