Repository navigation
fix(tools): measure a real cold start and set benchmark settings reliably - #31
Conversation
The app's notification listener is rebound about a second after am force-stop, which restarts the process, so the previous stop/sleep/ start measured a warm start. Disallow the app's enabled listeners around a dedicated cold start, wait until the process is gone, label the result cold or warm from the pid and ActivityManager's Start proc line, and restore the listeners right away and in the exit trap. The observation run uses a normal second start. Add --package to test the profile build. Document the second force-stop and the surface= check for settings written from outside the app (docs/PROFILING.md). Device validation on the AM6 pending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tore
Android 14 logs 'for next-top-activity {component}' and 'for service
{component}': compare only the reason word. The listener setting is
written asynchronously on Android 14, so poll for up to 5 s before
warning that it was not restored (verified on an AM9 Pro).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A process restarted by the listener that reads projectm_settings while it is being rewritten loads an empty map, and ProjectMApplication's one-time migrations then save that map over the new file. A second force-stop does not undo that: 1 of 16 runs on an AM9 Pro still got the defaults. Disallow the listener, stop, write, allow it again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3d9aba3823
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Record whether the profile app's listener is enabled and disallow and allow it only in that case, so the procedure does not grant notification access (Codex review). Use a shell function instead of an unquoted command variable so the snippet also works in zsh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91454b9eb3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
settings get without --user reads user 0, while cmd notification allow_listener/disallow_listener act on the current user. Read the current user's enabled_notification_listeners in tv-diagnostics.sh and in the profiling procedure, falling back to a plain read when an older settings command rejects --user current (Codex review). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc56e4f69e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
If the current user's enabled_notification_listeners cannot be read, leave the listener alone instead of reading user 0's setting, which could grant the current user access it never gave. The cold start is then reported as warm if Android restarts the app (Codex review). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
…r step Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9869fb50f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Clear LISTENERS_OFF only after the restore loop, so a Ctrl-C, TERM or lost adb connection during allow_listener leaves the exit trap to try again instead of skipping the restore (Codex review). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b819348f40
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Without a Start proc line for the activity or LaunchState COLD, an empty pid before the start does not prove a cold start (the listener could rebind in between). Label it unverified instead of cold (Codex review). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca75f78aae
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Require alternate package IDs to use a supplied matching APK or the installed app. Validate final option state before device access and cover source precedence in CI.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35a24c4c0d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Use a captured user ID for app operations and checked process discovery so other users cannot contaminate cold-start evidence. Write benchmark settings to that user’s data path and cover lookup failures and listener restoration.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ea3a02214
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Check other users before removing foreground-user app data. Fail closed when installation ownership cannot be verified, and report retained signing conflicts without attempting broader uninstall.
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
tools/tv-diagnostics.shreported a "cold start" that was usually a warm start. The app's notification listener (TrackListenerService) makes Android rebind it about a second afteram force-stop, which starts the app's process again, so the script'sforce-stop; sleep 1; am start -Wstarted the activity in an existing process. The same restart broke fixed-resolution benchmarks that writeprojectm_settings.xmlfrom outside the app (handover AM6 benchmarks: requested render height not applied, 2026-10-04): 12 of 72 runs rendered the previous run's height or the defaults.Testing on an AM9 Pro showed that the handover's fix (a second force-stop after the write) is not sufficient. A process that reads the file while it is being rewritten loads an empty map, and the one-time migrations in
ProjectMApplicationthen save that map over the new file. The documented procedure therefore disallows the listener during the write.No app code changes. The listener restarting the whole app (and running
ProjectMCore.init) in the background after any kill is noted in the handover as a product decision, not a defect; it is out of scope here.Changes
tools/tv-diagnostics.sh:am start -W, and allows the listeners again right away. The listeners are also restored by the exit trap (Ctrl-C, errors); a failed restore is printed with the manual command, in the log and insummary.md.Start proc <pid>:<package>/… for …activity, or Android reportsLaunchState: COLD; without positive evidence it says unverified, and otherwise explains why the time is not a cold-start time.am_start_cold.txt.--package IDto test the profile build (nl.neerdael.projectmtv.profile) with a matching--apkor--no-install, without replacing the release app. Alternate package IDs are rejected with the default build or--releasebefore adb/device access, because both modes supply the production package APK.tools/tv-diagnostics.shalso captures a numeric Android user once, scopes installation, permission grants, listener commands and activity stops/starts to that user, and filters numericpsUID/PID/NAME data by exact package process name and user. Failed, malformed or ambiguous lookups abort; the summary and manual listener-restore commands record the user. Signing-key recovery checks other users' exact package installations before deleting foreground-user data; another installation or unverifiable state is refused, and a retained conflict after the scoped retry is reported explicitly. No all-user removal is attempted.docs/PROFILING.md: new Fixed settings for a benchmark procedure (if the listener is enabled, disallow it → force-stop →pidofempty → write → allow it again only if it was enabled → start → checksurface=), with the measured reasons. Notification access ends up as it was. The procedure writes/data/user/<userId>/<package>/shared_prefs/projectm_settings.xmlfor the captured user and uses the same ID for its listener and activity commands; checked process queries and an exit trap protect the write/restore sequence.docs/DIAGNOSTICS.md:--package,am_start_cold.txt, and a Cold start section explaining the method and the manual restore command.README.md,AGENTS.md: the new option, supported package/APK-source combinations, the cold-start method and the listener restart lesson.tools/test_tv_diagnostics.pyand Android CI: Fake-adb tests cover 16 package/source combinations, Android 9/14-style user-10 launches alongside user-0 same-package processes, failed/malformed/ambiguous user/process queries, and listener restoration after a lookup failure, without a TV or build.Release notes
Internal
tools/tv-diagnostics.shmeasures a real cold start. Before, Android restarted the app for its notification listener right after the script stopped it, so the reported start time was usually a warm start. The script now disallows the listener briefly, waits until the app has exited, and allows the listener again; the summary labels each start time as cold or warm. New--packageoption to test the profile build with a matching--apkor--no-install. The default build and--releasereject alternate package IDs before connecting to the TV, preventing installation of an unrelated APK or measurement of a stale profile build.Validation
bash -n tools/tv-diagnostics.sh,shellcheck -S warning tools/tv-diagnostics.sh: clean.adb(stub reproducing the listener restart): normal TV → cold; process kept alive → labelled warm; Android 10+LaunchStatepath → cold; SIGTERM during the cold start → listener restored, exit 130; SIGTERM whileallow_listenerruns → the exit trap restores it; listener never enabled → nothing disallowed or allowed; restore failure → warning in log and summary;settings --user currentunreadable → listener left alone, start labelled warm.settings --user current get secure enabled_notification_listenersreturns the list on the AM6 (Android 9) and the AM9 Pro (Android 14).mainat 6ef76b6 (v2.3.0) in fd39a19, because CI's version step rejected the 2.2 base; no conflicts.mainat6244a3ec, merge35a24c4c), the APK, native engine and Preset Lab CI checks passed. Subsequent multi-user review corrections passpython3 -m unittest discover -s .github/scripts/tests(80 tests), diagnostics regression tests (9 methods / 37 cases, including 16 option combinations plus multi-user, lookup-failure, signing-conflict preservation and recovery scenarios),bash -n, ShellCheck,git diff --check, profiling snippetsh -n, and strict MkDocs build. Final head08c0666f2161e48d80f77a2f520f3ae930da428e: both push/PR APK builds, native engine tests and Preset Lab pass. Codex review completed for this head with no findings; all review threads are resolved../gradlew :app:assembleProfilebuilt the APK used on the TV.On a TV
nl.neerdael.projectmtv.profile), its listener enabled for the test. The Ugoos AM6 (Android 9) was asleep and was not used; Android 9 support ofcmd notification allow_listener/disallow_listenerwas checked there read-only.am force-stop,Start proc …profile/u0a114 for service {…TrackListenerService}within a second andLaunchState: WARMon the next start.tools/tv-diagnostics.sh 192.168.51.53:5555 --no-install --package nl.neerdael.projectmtv.profile --duration 30, 6 runs. Every cold start was a new processfor next-top-activitywithLaunchState: COLD; the observation start was the listener-started process. Listener enabled after each run;debug.projectmtv.presetempty. "Track titles off" appears only in the cold-start process; no dialog in the screenshots.render_height720/1080, checking every STATSsurface=: single force-stop 8/8 correct (the race is timing-dependent and rarer on this box); second force-stop after the write 15/16 (one run got the defaults: 1080p Auto at the 30 fps cap); listener disallowed during the write 3/3 before the TV went to sleep.debug.projectmtv.*properties cleared and app settings restored afterwards (profile settings file and listener list returned to their state before the test; the profile build stays installed).Evidence
Runs 1–3 still had the restore check's false warning (Android 14 writes the setting asynchronously), fixed in bf84ff0; the listener was in fact restored after each run. Runs 4–6 were made with the final script.
Docs and release
README.md, the user guide (docs/user-guide/*.md; none mentions the diagnostics script or benchmark settings),docs/DIAGNOSTICS.md,docs/PROFILING.md,docs/ARCHITECTURE.md(mentions the script only as a command for startup and FPS data; still accurate),AGENTS.mdand the other Markdown files that mentiontv-diagnostics.sh(RELEASE_NOTES.md, historical). UpdatedREADME.md(developer diagnostics paragraph),docs/DIAGNOSTICS.md,docs/PROFILING.md,AGENTS.md. The user guide needs no diagnostics-source change: its development page links the corrected README and contains no conflicting package command. Verified Pages destination: https://johnneerdael.github.io/ProjectM-TV/, published fromdocs/user-guide/via.github/workflows/docs.yml; strict build passes after integrating feat(core): define legacy shader inputs and prove initialization #33.Release notessection matches the final change and contains no placeholders or test logsNot tested / known limitations
--package; the script does not inspect them.LaunchState,Start proc … for activity) is covered by the simulation and by the handover's AM6 logs only.kill -9during the cold start, the listener stays disallowed until restored by hand (command indocs/DIAGNOSTICS.md).🤖 Generated with Claude Code