Closed Bug 2081811 Opened 1 month ago Closed 1 month ago

AiTab: [FE] Do not await font to load page contents

Categories

(Core :: Machine Learning: General, defect, P1)

defect
Points:
2

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: mlucks, Assigned: mlucks)

References

(Blocks 1 open bug)

Details

(Whiteboard: [aiaug])

Attachments

(1 external file)

Currently the custom font for Smart Page hinders first load TTFB by around 700ms. Most of this time is waiting on the Remote Settings server to respond. 2 calls are made to connect to RS before the font itself starts to download. Since these 2 preliminary calls are inexpensive, barely 1kb each, we can split those two off, and "open the tunnel" to RS as soon as a user opens a Smart Window. By doing this, the TTFB on a Smart Page dramatically reduces (the font file itself is 66kb and takes around 70-80ms to download)

Before Fix (Profile 1): first load, first contentful paint at 741ms
Before Fix (Profile 2): second load, first contentful paint at 69ms

We prototyped a fix and received these results from the profile:

After Fix: first load, first contentful paint at 58ms

This task is to take that prototype and implement it into the codebase

Points: 1 → 2

AITabHeadingFont.sys.mjs only starts work from AITabParent.actorCreated, and #handleGetPage waits for the font before it returns the page (AITabParent.sys.mjs, #136). On a fresh profile, ai-window-aitab has no JSON dump, so client.get() has to pull the startup bundle or sync from the server first. That includes the server-info fetch behind Utils.baseAttachmentsURL(), and it all happens before the attachment download starts.

Fix: Export a prewarmHeadingFont() that calls client.get({ filters: { name: HEADING_FONT_RECORD_NAME } }) without downloading the attachment, swallows errors, and returns early unless browser.smartwindow.aitab.enabled is set. Call it fire-and-forget next to the two _startSchedulers() calls in AIWindow.sys.mjs: the active-window branch of init() and the isTogglingToAIWindow branch of toggleAIWindow() at #1215. This follows the getAllModelsData() warm-up at #220. Then extend browser_aitab_heading_font.js to check that the prewarm fills the local records without fetching the font.

Suggested severity: S3. Smart Page's first paint on a cold profile is about 700ms late in a pref-gated feature, and later loads are fast once Remote Settings has synced.


If you'd like to provide feedback on this comment, please use the 👍 or 👎 reaction.
If you want to categorize your feedback you can add one of the following tags: ai-triage-{wrong-file, wrong-cause, hallucination, out-of-scope, not-a-bug, wrong-fix, shallow-fix, wrong-severity}.

Needinfo hackbot@mozilla.tld to have a patch generated for this bug, include any questions or directions as needed in your comment.

Summary: AiTab: [FE] Break up Remote Settings network calls to enhance custom font load time → AiTab: [FE] Do not await font to load page contents

Weve changed directions, instead, just let the font come when it comes, and accept that first loads will experience a font flash on loading. If there comes a time when we need remote settings more globally, or find another path to prevent the flash, we can address at that time

Attachment #9661692 - Attachment description: Bug 2081811 - Defer the font load, dont let it hinder page load - r?omarg → Bug 2081811 - Font downloads during page generation and will not block page render - r?omarg
Attachment #9661692 - Attachment description: Bug 2081811 - Font downloads during page generation and will not block page render - r?omarg → Bug 2081811 - Font downloads during page generation and will not block page render - r?omarg,rrando
Pushed by ogonzalez@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/b363a218a9d3 https://hg.mozilla.org/integration/autoland/rev/1112b07b4131 Font downloads during page generation and will not block page render - r=omarg,rrando
Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
QA Whiteboard: [qa-triage-done-c161/b160]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: