You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
4.2 KiB
4.2 KiB
Prefetch Investigation Summary
Problem Statement
The daily notification prefetch job (T-5 min) is not calling the native fetcher, resulting in:
from: nullin prefetch logs- Fallback/mock content being used
DISPLAY_SKIP content_not_foundat notification time- Storage empty (
[]) when display worker runs
Root Cause Hypothesis
Based on the directive analysis, likely causes (ranked):
- Registration Timing: Prefetch worker runs before
Application.onCreate()completes - Discovery Failure: Worker resolves fetcher to
null(wrong scope, process mismatch) - Persistence Bug: Content written but wiped/deduped before display
- ID Mismatch: Prefetch writes
notify_...but display looks fordaily_...
Instrumentation Added
TimeSafariApplication.java
APP|ON_CREATE ts=... pid=... processName=...- App initialization timingFETCHER|REGISTER_START instanceHash=... ts=...- Before registrationFETCHER|REGISTERED providerKey=... instanceHash=... registered=... ts=...- After registration with verification
TimeSafariNativeFetcher.java
FETCHER|CONFIGURE_START instanceHash=... pid=... ts=...- Configuration startFETCHER|CONFIGURE_COMPLETE instanceHash=... configured=... apiBaseUrl=... activeDid=... jwtLength=... ts=...- Configuration completionPREFETCH|START id=... notifyAt=... trigger=... instanceHash=... pid=... ts=...- Fetch startPREFETCH|SOURCE from=native/fallback reason=... ts=...- Source resolutionPREFETCH|WRITE_OK id=... items=... ts=...- Successful fetch
Diagnostic Tools
Log Filtering Script
./scripts/diagnose-prefetch.sh app.timesafari.app
Filters logcat for:
APP|ON_CREATEFETCHER|*PREFETCH|*DISPLAY|*STORAGE|*
Manual Filtering
adb logcat | grep -E "APP\|ON_CREATE|FETCHER\||PREFETCH\||DISPLAY\||STORAGE\|"
Investigation Checklist
A. App/Plugin Initialization Order
- Confirm
APP|ON_CREATEappears beforePREFETCH|START - Verify
FETCHER|REGISTERED registered=true - Check for multiple
onCreateinvocations (process restarts) - Confirm single process (no
android:processon workers)
B. Prefetch Worker Resolution
- Check
PREFETCH|SOURCE from=native(notfrom=fallback) - Verify
instanceHashmatches between registration and fetch - Compare
pidvalues (should be same process) - Check
FETCHER|CONFIGURE_COMPLETE configured=truebefore prefetch
C. Storage & Persistence
- Verify
PREFETCH|WRITE_OK items>=1 - Check storage logs for content persistence
- Compare prefetch ID vs display lookup ID (must match)
D. ID Schema Consistency
- Prefetch ID format:
daily_<epoch>ornotify_<epoch> - Display lookup ID format: must match prefetch ID
- Verify ID derivation rules are consistent
Next Steps
- Run diagnostic script during a notification cycle
- Analyze logs for timing issues and process mismatches
- If fetcher is null: Implement Fix #2 (Pass Fetcher Context With Work) or Fix #3 (Process-Safe DI)
- If ID mismatch: Normalize ID schema across prefetch and display
- If storage issue: Add transactional writes and read-after-write verification
Expected Log Flow (Success Case)
APP|ON_CREATE ts=... pid=... processName=app.timesafari.app
FETCHER|REGISTER_START instanceHash=... ts=...
FETCHER|REGISTERED providerKey=DailyNotificationPlugin instanceHash=... registered=true ts=...
FETCHER|CONFIGURE_START instanceHash=... pid=... ts=...
FETCHER|CONFIGURE_COMPLETE instanceHash=... configured=true ... ts=...
PREFETCH|START id=daily_... notifyAt=... trigger=prefetch instanceHash=... pid=... ts=...
PREFETCH|SOURCE from=native instanceHash=... apiBaseUrl=... ts=...
PREFETCH|WRITE_OK id=daily_... items=1 ts=...
STORAGE|POST_PREFETCH total=1 ids=[daily_...]
DISPLAY|START id=daily_...
STORAGE|PRE_DISPLAY total=1 ids=[daily_...]
DISPLAY|LOOKUP result=hit id=daily_...
Failure Indicators
PREFETCH|SOURCE from=fallback- Native fetcher not resolvedPREFETCH|SOURCE from=null- Fetcher registration failedFETCHER|REGISTERED registered=false- Registration verification failedSTORAGE|PRE_DISPLAY total=0- Content not persistedDISPLAY|LOOKUP result=miss- ID mismatch or content cleared