Repository navigation
perf(web-watcher): rate-limit page-title lookups - #345
Merged
ErikBjare merged 4 commits intoOct 11, 2026
Merged
Conversation
|
7 of 20 tasks
0xbrayo
force-pushed
the
perf/web-watcher-title-lookup
branch
from
October 8, 2026 19:37
b9c9bc1 to
3c54f6f
Compare
Member
Author
Member
Author
Every content-change event from a browser walked the event's subtree for a WebView title (up to 2000 binder calls on the service's main thread), including for Firefox where the lookup can never match. Skip Firefox and look the title up at most every 500ms while it is unknown and every 5s once found.
A rate-limited lookup could miss the title for good: if the event that carried it was skipped and the page then went quiet, the session ended with an empty title. When an event is skipped, schedule one lookup for when the gate next allows it, on a fresh tree from rootInActiveWindow while the same browser is still in front. The timing moves into TitleLookupGate with an injected clock so its boundaries are unit-tested.
…changes A single global pending flag blocked the follow-up for a newly opened browser while one for the previous browser was waiting, and the old one then exited because the session had moved on. Track which browser the pending follow-up is for and replace it on a switch.
0xbrayo
force-pushed
the
perf/web-watcher-title-lookup
branch
from
October 11, 2026 13:13
aed48e1 to
d0c9bc1
Compare
Member
Author
…check A pending 5s recheck for the same browser blocked scheduling the 500ms retry a newly opened page needs, so its title could be lost if the user left the page before the recheck ran. Track when the pending follow-up runs and replace it when the new one is due sooner.
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #333.
WebWatchersubscribes totypeWindowContentChanged, which a browser emits up to every 100 ms (notificationTimeout) while a page is loading or animating. For every such event it ranfindWebView, a bounded walk of the event's subtree of up toMAX_TRAVERSAL_NODES(2000)getChildbinder calls, on the accessibility service's main thread. For Firefox the walk can never match (documented onfindWebView), so it was pure cost.Change
BrowserSessionTrackerexposeshasTitle(title seen since the URL last changed).Testing
./gradlew :mobile:testStandardDebugUnitTestpasses.