Skip to content

ADFA-2580 | Fix Koin init crash on Editor launch - #858

Merged
jatezzz merged 1 commit into
stagefrom
fix/ADFA-2580-koin-init-crash
Jan 22, 2026
Merged

ADFA-2580 | Fix Koin init crash on Editor launch#858
jatezzz merged 1 commit into
stagefrom
fix/ADFA-2580-koin-init-crash

Conversation

@jatezzz

@jatezzzjatezzz commented Jan 20, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Moved Koin initialization to IDEApplication and added a safe guard to avoid future double-start issues.
  • Restored ProjectManagerImpl.projectPath earlier in BaseEditorActivity before fragment/ViewModel creation to prevent UninitializedPropertyAccessException.
  • Reset editor ViewModel flags on activity creation to ensure consistent state after recreation.

Details

  • Verified Editor launch after process death / activity recreation (e.g., returning from recents) no longer crashes with InstanceCreationException / projectPath not initialized.
  • No UI changes included.
Screen.Recording.2026-01-20.at.1.44.15.PM.mov

Ticket

ADFA-2580

Observation

  • The crash was caused by DI creating ChatViewModel before projectPath was restored, so the fix ensures required state is available before Koin-resolved components access it.
  • ensureKoinStarted() is defensive: it prevents accidental future regressions if another startup path is introduced.

@coderabbitai

coderabbitaiBot commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@jatezzz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 30 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Relocates Koin DI startup from DeviceProtectedApplicationLoader to IDEApplication (ensureKoinStarted called in onCreate). BaseEditorActivity restores saved project path via a scoped read from savedInstanceState and initializes editorViewModel flags isBuildInProgress and isInitializing to false in onCreate.

Changes

Cohort / File(s)Summary
DI Initialization Refactoring
app/src/main/java/com/itsaky/androidide/app/IDEApplication.kt, app/src/main/java/com/itsaky/androidide/app/DeviceProtectedApplicationLoader.kt
Removed Koin bootstrap from DeviceProtectedApplicationLoader; added ensureKoinStarted() and call in IDEApplication.onCreate with a guard to avoid re-starting Koin (checks GlobalContext).
Editor lifecycle / state init
app/src/main/java/com/itsaky/androidide/activities/editor/BaseEditorActivity.kt
Restore saved project path from savedInstanceState using a scoped read and set it on ProjectManagerImpl; initialize editorViewModel.isBuildInProgress and editorViewModel.isInitializing to false in onCreate.

Sequence Diagram(s)

sequenceDiagram
participant Loader as DeviceProtectedApplicationLoader
participant App as IDEApplication
participant Koin as Koin(GlobalContext)
Loader->>App: continue startup (no Koin start)
App->>Koin: ensureKoinStarted() in onCreate
alt Koin not started
App->>Koin: startKoin(modules...)
Koin-->>App: initialized
else Koin already started
App-->>Koin: skip start
end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • itsaky-adfa
  • jomen-adfa

Poem

🐰 I hopped from loader into app’s bright light,

Koin seeds were planted in the app tonight,
Paths remembered, viewmodels set to play,
Small hops, tidy starts, we nibble bugs away,
🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Title check✅ PassedThe title clearly summarizes the main change: moving Koin initialization to fix a crash on Editor launch. It is concise, specific, and directly related to the primary purpose of the changeset.
Description check✅ PassedThe description is comprehensive and directly related to the changeset, detailing the three main changes (moving Koin init, restoring projectPath, resetting ViewModel flags) with clear explanations and verification details.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jatezzz
jatezzz requested a review from a teamJanuary 20, 2026 20:09
@jatezzz
jatezzzforce-pushed the fix/ADFA-2580-koin-init-crash branch 2 times, most recently from dd5387d to b0cf618CompareJanuary 21, 2026 13:53
@Daniel-ADFA

Copy link
Copy Markdown
Contributor

LGTM! Moving koin to the IDEApplication is faster so we don't have direct boot issues

@jatezzz
jatezzzforce-pushed the fix/ADFA-2580-koin-init-crash branch from 453a5ad to a71cad8CompareJanuary 21, 2026 14:39
Prevent ChatViewModel DI crash after process recreation
@jatezzz
jatezzzforce-pushed the fix/ADFA-2580-koin-init-crash branch from 7b12f25 to 70f377dCompareJanuary 22, 2026 13:20
@jatezzz
jatezzz merged commit 3e05158 into stageJan 22, 2026
2 checks passed
@jatezzz
jatezzz deleted the fix/ADFA-2580-koin-init-crash branch January 22, 2026 13:30
@coderabbitaicoderabbitaiBot mentioned this pull request Feb 14, 2026
jatezzz added a commit that referenced this pull request Jun 22, 2026
fix: guard Koin startup and restore projectPath early
Prevent ChatViewModel DI crash after process recreation
Sign up for freeto 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.

2 participants

@jatezzz@Daniel-ADFA