Skip to content

Defer unused home feature initialization on mapless launches - #2335

Open
bmander wants to merge 1 commit into
mainfrom
fix/2330-lazy-home-features
Open

bmander wants to merge 1 commit into
mainfrom
fix/2330-lazy-home-features

Conversation

@bmander

@bmander bmander commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

List and arrivals-board launches currently resolve all home feature ViewModels before navigation's map-readiness gate can exclude HOME. Resolve each feature independently on first use, and create the dependency holder once per activity. Mapless startup still receives help/migration dialogs, while map, survey, donation, weather, planner, results, and pinned-trip initialization waits for HOME or an explicit launch action.

The existing activity-scoped delegates, SavedStateHandle creation extras, and initial/warm intent processing remain the owners of state and delivery.

Validation:

  • Android CI passed (formatting, unit tests, checks, and API 33 device suite). CodeRabbit reported no actionable findings.
  • 582 focused home, trip-planner, and trip-results unit tests passed.
  • 24 tests passed on the connected Pixel 7 Pro, including seven new production-Activity tests for list/board/shortcut deferral, subsequent map entry, cold/warm trip notifications, and recreation/instance retention. Existing launch-ordering and saved-state tests also passed.
  • Debug app and test APKs compiled with warnings as errors; Spotless applied and diff checks passed.
  • Both baseline and fixed release APKs built successfully with R8, resource shrinking, and warnings as errors; their manifests were verified non-debuggable. The local debug key was used only for signing.

Warm-start comparison (Pixel 7 Pro, 12 GB; baseline 809361336 vs fix 9369af755):

First-display timing Before After
Median 53 ms 50 ms
Range 47–63 ms 45–56 ms

Ten explicit homeStarredStops launches per build, after three warmups, using am start -W with NEW_TASK | CLEAR_TASK; Android reported WARM and the process PID stayed constant within each batch. System traces (am, wm, view, gfx, dalvik) were captured. This measures repeated activity creation with hot process caches; it does not reproduce low-memory process restoration. The small difference is not evidence of a production startup improvement.

Useful-content readiness was not timed: TotalTime is the first-display boundary and must not be treated as arrivals/list readiness. The 3–4 GB cohort and real process-death restoration remain unmeasured. The regression tests establish removal of unused feature initialization; this change does not establish the cause of the Play Console warning.

Fixes #2330.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 7b70b841-8d4e-4d6d-be2f-87b0eff23221

📥 Commits

Reviewing files that changed from the base of the PR and between 8093613 and 9369af7.

📒 Files selected for processing (3)
  • onebusaway-android/src/androidTest/java/org/onebusaway/android/ui/HomeFeatureInitializationTest.kt
  • onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.kt
  • onebusaway-android/src/main/java/org/onebusaway/android/ui/home/HomeNavHost.kt

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

HomeDestinationDeps now resolves optional home ViewModels lazily. HomeActivity hoists one dependency holder into composition. New instrumentation tests verify mapless launches, map entry, trip notifications, and state retention across recreation.

Changes

Home feature initialization

Layer / File(s) Summary
Lazy dependency contract
onebusaway-android/src/main/java/org/onebusaway/android/ui/home/HomeNavHost.kt
HomeDestinationDeps accepts provider lambdas for optional ViewModels and exposes them through lazy properties.
Activity dependency wiring
onebusaway-android/src/main/java/org/onebusaway/android/ui/HomeActivity.kt, onebusaway-android/src/main/java/org/onebusaway/android/ui/home/HomeNavHost.kt
HomeActivity builds one HomeDestinationDeps instance before setContent and passes it to HomeNavHost.
Initialization and restoration validation
onebusaway-android/src/androidTest/java/org/onebusaway/android/ui/HomeFeatureInitializationTest.kt
Instrumentation tests verify deferred map-feature initialization, map entry, trip-notification planning, and ViewModel and plan retention across recreation.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant HomeActivity
  participant HomeNavHost
  participant HomeDestinationDeps
  participant FeatureViewModel
  HomeActivity->>HomeDestinationDeps: create provider-backed dependency holder
  HomeActivity->>HomeNavHost: pass stable dependency holder
  HomeNavHost->>HomeDestinationDeps: access ViewModel when destination or action needs it
  HomeDestinationDeps->>FeatureViewModel: resolve Activity-scoped ViewModel
  FeatureViewModel-->>HomeNavHost: provide feature state
Loading

Merge Risk: ⚪ Minimal · up to 9369a

This change defers unused Home feature setup during mapless launches while preserving map entry, notifications, and restored state. The covered behavior is merge-ready with no remaining merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy the coding requirements in [#2330]. HomeActivity creates one HomeDestinationDeps holder and passes providers for optional ViewModels. HomeDestinationDeps stores those provide…
Out of Scope Changes check ✅ Passed The reviewed changes stay within [#2330]. They modify HomeActivity, HomeNavHost, and focused instrumentation tests for deferred feature initialization, launch actions, and state retention. The cha…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: deferring unused home feature initialization during mapless launches.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

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.

Defer unused home feature initialization during activity startup

1 participant