kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Android app stays on the splash screen on first launch after install when Python init fails

Open rtibblesbot opened this issue 4 weeks ago • 2 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Target branch: release-v0.20.x

Observed behavior

  • On the first launch after install, the main process and :task_worker both start Python and extract chaquopy's AssetFinder/requirements at the same moment.
  • :task_worker crashed in App.onCreate and Android restarted it, after which it initialised normally.
  • The main process's KolibriEnvironmentInitializer failed, so KolibriServerService never started the HTTP server.
  • The app stayed on the splash screen until force-stopped; the next launch reached the setup wizard.

Errors and logs

:task_worker:

E AndroidRuntime: java.lang.RuntimeException: Unable to create application org.learningequality.Kolibri.App: com.chaquo.python.PyException: FileNotFoundError: [Errno 2] No such file or directory: 'noto-subset.pt-br-0b75e6d0bb605251080ffc9c7a7902a8.css.gz.t47hdr62'

Main process, raised while monkey_patch_zeroconf was being imported:

E KolibriEnvInitializer: com.chaquo.python.PyException: FileNotFoundError: [Errno 2] No such file or directory: '/data/data/org.learningequality.Kolibri/files/chaquopy/AssetFinder/requirements/kolibri/dist/django/contrib/admin/static/admin/js/vendor/select2/i18n/hsb.js.gz.3h22j7e0'
	at <python>.tempfile.NamedTemporaryFile(tempfile.py:575)
	at <python>.java.chaquopy.import_override(import.pxi:26)
	at <python>.monkey_patch_zeroconf.<module>(monkey_patch_zeroconf.py:2)
	...
	at org.learningequality.Kolibri.KolibriEnvironmentInitializer.initializeKolibri(KolibriEnvironmentInitializer.java:138)
E KolibriServerService: java.util.concurrent.CompletionException: java.lang.RuntimeException: Failed to initialize Kolibri

User-facing consequences

  • A user who has just installed Kolibri sees only the splash screen and has to force-stop the app to get past it.

Steps to reproduce

  1. Install the debug APK built from release-v0.20.x (seen on 0.20.0a2.dev1730+g5a35a50b7) on an API 30 emulator.
  2. Launch Kolibri from the launcher before it has ever run.
  3. Watch adb logcat for the errors above while the splash screen stays up.

Context

  • Kolibri 0.20.0a2.dev1730+g5a35a50b7-debug
  • Android 11 (API 30) x86_64 emulator

Acceptance Criteria

  • [ ] The first launch after install reaches the setup wizard without a force-stop.
  • [ ] Neither process logs a FileNotFoundError from chaquopy asset extraction on that launch.

AI usage

Claude Code hit this during automated Android QA of the #15765 branch, captured the logcat, and drafted this issue.

rtibblesbot avatar Nov 05 '26 15:11 rtibblesbot

Plan: First launch after install reaches the setup wizard: the main and :task_worker processes no longer delete each other's Chaquopy asset extraction.

  • [ ] Cross-process lock helper
  • [ ] Take the lock around Python startup and the kolibri import
  • [ ] Self-review the produced code

Assumptions — the issue did not settle these; say so if one is wrong.

  • No prefs flush after Python.start: the lock is held through the kolibri extraction, which outlasts apply(). If wrong, a late rmtree remains; add an empty edit().commit() on Chaquopy's prefs.
  • No lock-wait timeout, unlike migration_lock.py: the OS releases the lock when its holder dies. If a hung holder must be survived, poll tryLock against a deadline.
  • Chaquopy supports Python.start off the main thread. If not, the start stays on the main thread, and waiting for the lock there risks an ANR.
  • Init failure still leaves the splash screen up with no retry. If recovery is wanted, KolibriServerService needs a retry path, which this branch does not add.

Written by rtibblesbot, an LLM-based coding agent.

rtibblesbot avatar Nov 05 '26 16:11 rtibblesbot

Fixed in #15768

rtibbles avatar Nov 06 '26 02:11 rtibbles