Skip to content

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

Merged
wernrab merged 1 commit into
opencloud-eu:mainfrom
welcometopwn:fix/documents_provider_koin_startup
Nov 23, 2026
Merged

wernrab merged 1 commit into
opencloud-eu:mainfrom
welcometopwn:fix/documents_provider_koin_startup

Conversation

@welcometopwn

@welcometopwn welcometopwn commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

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

@wernrab wernrab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix

@wernrab
wernrab merged commit ecf1a32 into opencloud-eu:main Nov 23, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in OpenCloud Team Board Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

DocumentsStorageProvider throws NoBeanDefFoundException when OpenCloud isn't running

2 participants

⌂ Proxy