Fix foreground parser's synchronous EndIfDelayed behaviour
EndIfDelayed stops document parsing if all scripts and resources are complete. To do this, it calls PumpTokenizer one last time to ensure that there's no input left to parse. Because it wasn't possible to delay work in this context, it meant that if something needed to call EndIfDelayed, PumpTokenizer could spend a long time processing all the available input, delaying first paint. It looked something like this in chrome://tracing: | HTMLDocumentParser::ResumeParsingAfterPause | | PumpTokenizer (budgeted) | EndIfDelayed | | | PumpTokenizer (unlimited budget) | This change adds new methods to permit this schedule instead: | ResumeParsingAfterPause |<paint>|PumpTokenizer (budgeted)|<paint> | ScheduleEndIfDelayed | The parser (via DeferredPumpTokenizerIfPossible) then schedules further tokenizer pumps until every piece of input's handled, and finally calls EndIfDelayed. |PumpTokenizer (budgeted)|<paint>| EndIfDelayed | |PumpTokenizer (unlimited budget)| Because there are more opportunities for painting to happen under this schedule, this CL improves this parsing mode's TTFP and also makes tuning the foreground tokenizer budget easier and more effective. Bug: 901056 Change-Id: I55d7f045e352ada239bffea65fe687b167160fb5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2274629 Commit-Queue: Richard Townsend <richard.townsend@arm.com> Reviewed-by:Mason Freed <masonfreed@chromium.org> Cr-Commit-Position: refs/heads/master@{#786207}
Showing
Please register or sign in to comment