Skip to content

fix: documents provider crashes on cold start before Koin is ready - #263

Open
welcometopwn wants to merge 1 commit into
opencloud-eu:mainfrom
welcometopwn:fix/documents_provider_koin_startup
Open

welcometopwn wants to merge 1 commit into
opencloud-eu:mainfrom
welcometopwn:fix/documents_provider_koin_startup

Conversation

@welcometopwn

@welcometopwn welcometopwn commented Nov 19, 2026 •

Copy link
Copy Markdown

Fixes #238

If OpenCloud isn't running and another app opens one of its files through a saved SAF URI (a password manager reading its database, for example), Android starts OpenCloud just for the documents provider. The first query can come in on a binder thread while MainApp.onCreate() hasn't finished startKoin yet, so it fails and the other app thinks the file is gone. Retrying works because Koin is up by then.

On 1.2.5 this showed up as NoBeanDefFoundException, on 1.3.1 I get:

E DatabaseUtils: java.lang.IllegalStateException: KoinApplication has not been started
E DatabaseUtils:   at org.koin.core.context.GlobalContext.get(GlobalContext.kt:36)
E DatabaseUtils:   at ...DocumentsStorageProvider.getFileByIdOrException(DocumentsStorageProvider.kt:791)
E DatabaseUtils:   at ...DocumentsStorageProvider.queryDocument(DocumentsStorageProvider.kt:333)

Fix

  • MainApp counts down a latch once startKoin has loaded all modules; awaitDependencyInjection() waits for it (10 s max, logs a warning on timeout).
  • DocumentsStorageProvider gets a private inject() that shadows Koin's extension: it waits for the latch, then resolves from GlobalContext. All existing by inject() call sites stay unchanged.

Tested on a Galaxy S25+ (Android 17): force-stopped both apps and let the other app read the file again. The store build fails on the first query, with this change it works.

@github-project-automation github-project-automation Bot moved this to Qualification in OpenCloud Team Board Nov 20, 2026
@kulmann
kulmann requested a review from wernrab November 20, 2026 09:45
@kulmann kulmann moved this from Qualification to Needs Review in OpenCloud Team Board Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

DocumentsStorageProvider throws NoBeanDefFoundException when OpenCloud isn't running

1 participant