Skip to content

Reinitialise repo on main activity (re)creation - #202

Merged
wiiznokes merged 1 commit into
wiiznokes:masterfrom
tlvince:fix/repo-not-init-remember
Jul 29, 2026
Merged

Reinitialise repo on main activity (re)creation#202
wiiznokes merged 1 commit into
wiiznokes:masterfrom
tlvince:fix/repo-not-init-remember

Conversation

@tlvince

@tlvince tlvince commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

This ensures the repo is properly opened if the main activity is killed/re-opened.

Tested via:

  1. used this branch to add some debug logs: master...tlvince:gitnote:repo-not-init-logs
  2. started the app with network online (triggering a sync)
  3. disable the network (via GrapheneOS' network permission toggle)
  4. make a change to a note, saw the following logs:
  D StorageManager: update: commitMessage=gitnote modified gitnote.md, isRepoInitialized=false
  D GitManager:   safelyAccessLibGit2: commitAll (isRepoInitialized=false, isLibInitialized=false)
  D GitManager:   res on init = 0
  D GitManager:   commit all: <redacted>
  W GitManager:   commitAll: isRepoInitialized is false, throwing RepoNotInit
  W GitManager:   safelyAccessLibGit2: operation 'commitAll' failed
  W GitManager:   io.github.wiiznokes.gitnote.manager.GitException: RepoNotInit
  E StorageManager: update: commitAll (before) failed: RepoNotInit

With this and the same steps, after the process is recreated, tryInit runs and I can't repro.

Closes #196, closes #197.

@wiiznokes

wiiznokes commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Are you closing the app somewhere in your steps ?
The re creation of the activity shouldn't cause isRepoInitialized to be set to false, because it is tied to class MyApp : Application()

Is there a difference in GrapheneOS that you're aware?

@tlvince

tlvince commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Are you closing the app somewhere in your steps ?

Ah, not explicitly, but I do have "allow background usage" disabled. Could you test with that?

I think issue can still happen without this (as well as stock Android), just less frequently.

@wiiznokes

Copy link
Copy Markdown
Owner

So rememberSaveable can restore state after process recreation, so yeah it can cause issues.

Thanks for the fix

@wiiznokes
wiiznokes force-pushed the fix/repo-not-init-remember branch from 2f5f504 to 3e2c530 Compare July 29, 2026 16:41
@wiiznokes
wiiznokes enabled auto-merge (rebase) July 29, 2026 16:41
@wiiznokes
wiiznokes merged commit b2649dc into wiiznokes:master Jul 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RepoNotInit error when network is down

2 participants