New Tab scripts cached in the ScriptPreloader are not invalidated during a train-hop
Categories
(Firefox :: New Tab Page, defect)
Tracking
()
People
(Reporter: mconley, Assigned: mconley)
References
(Blocks 2 open bugs)
Details
Attachments
(2 external files)
SuAnn noticed that on her release instance of Firefox, that she still had a bug present on the New Tab page that we were certain we'd fixed with a train-hop (a train-hop that SuAnn had installed).
After a pretty wide-ranging debugging session, we learned:
- That the train-hop was correctly installed
- That the resource mapping to the XPI was working correctly
- That the expected fix was indeed in the XPI that we shipped
Nonetheless, the fix did not appear, until SuAnn flushed her startupcache. That's when something in my memory tickled me, back from 2018: bug 1416066.
In that bug, we realized that newtab wasn't taking advantage of the ScriptPreloader bytecode cache, which meant that the newtab scripts were being parsed at runtime - and at the time, we were under pressure to find performance optimizations. So we jumped through some hoops to add support for the ScriptPreloader bytecode cache for the newtab scripts.
That bytecode cache is meant for the static JavaScript that ships with the browser - those scripts are parsed only the first time, and the resulting bytecode is cached. Subsequent starts skip the parsing step and simply re-execute the bytecode from the cache, until the next major version upgrade (which invalidates the cache).
The problem is that our newtab scripts are still getting cached, and the cache does not invalidate when we do a train-hop.
This means that while the sys.mjs files that power newtab may get updated, the content scripts in this list might all still be the cached versions from before the train-hop! That's bad - that means we run the risk of the renderer being out-of-date compared to the state object it gets from the parent.
At this stage, I think the ScriptPreloader is probably more trouble than it's worth, and we should probably aim to skip the bytecode cache entirely, since there's not really a way to invalidate the newtab files (we can only invalidate the entire startup cache for the whole browser).
| Assignee | ||
Updated•1 year ago
|
| Assignee | ||
Comment 1•1 year ago
|
||
This is a safe, upliftable change that gets us off of the ScriptPreloader. The next logical
step is to get rid of the noscript version of the activity-stream HTML page, and load the
scripts on the page "normally" with <script> tags. That will occur in bug 1998468.
| Assignee | ||
Comment 2•1 year ago
|
||
[Tracking Requested - why for this release]:
I'm hoping this fix can be considered for the planned 145 dot release once the patch here merges to Nightly and has a few days of manual testing.
Comment 5•1 year ago
|
||
Revert for causing bc failures on browser_ext_contentscript_sender_url.js.
[task 2025-11-05T21:26:05.454+00:00] 21:26:05 INFO - TEST-PASS | browser/components/extensions/test/browser/browser_ext_contentscript_sender_url.js | Correct sender.origin: http://mochi.test:8888 -
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - Console message: [JavaScript Error: "NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXPCComponents_Utils.cloneInto]" {file: "resource://gre/actors/RemotePageChild.sys.mjs" line: 103}]
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - receiveMessage@resource://gre/actors/RemotePageChild.sys.mjs:103:28
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - JSActor query*send@resource://newtab/lib/ActivityStreamMessageChannel.sys.mjs:125:14
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - middleware/</<@resource://newtab/lib/ActivityStreamMessageChannel.sys.mjs:74:14
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - _middleware/</<@resource://newtab/lib/Store.sys.mjs:47:11
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - Store/this[method]@resource://newtab/lib/Store.sys.mjs:27:54
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - reply@resource://newtab/lib/NewTabInit.sys.mjs:29:16
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - onAction@resource://newtab/lib/NewTabInit.sys.mjs:41:14
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - _middleware/</<@resource://newtab/lib/Store.sys.mjs:50:17
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - Store/this[method]@resource://newtab/lib/Store.sys.mjs:27:54
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - onActionFromContent@resource://newtab/lib/ActivityStreamMessageChannel.sys.mjs:94:10
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - onMessage@resource://newtab/lib/ActivityStreamMessageChannel.sys.mjs:331:10
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - notifyActivityStreamChannel@resource:///actors/AboutNewTabParent.sys.mjs:148:18
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - receiveMessage@resource:///actors/AboutNewTabParent.sys.mjs:116:14
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - JSActor query*RPMSendAsyncMessage@resource://gre/actors/RemotePageChild.sys.mjs:146:10
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - accessCheckedFn@resource://gre/actors/RemotePageChild.sys.mjs:77:30
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - messageMiddleware/</<@resource://newtab/data/content/activity-stream.bundle.js:16806:24
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - rehydrationMiddleware/</<@resource://newtab/data/content/activity-stream.bundle.js:16837:14
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - renderWithoutState/<@resource://newtab/data/content/activity-stream.bundle.js:16951:11
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO -
[task 2025-11-05T21:26:05.456+00:00] 21:26:05 INFO - Buffered messages finished
[task 2025-11-05T21:26:05.457+00:00] 21:26:05 INFO - TEST-UNEXPECTED-FAIL | browser/components/extensions/test/browser/browser_ext_contentscript_sender_url.js | Test timed out -
[task 2025-11-05T21:26:05.457+00:00] 21:26:05 INFO - GECKO(1481) | Completed ShutdownLeaks collections in process 1481
[task 2025-11-05T21:26:05.458+00:00] 21:26:05 INFO - TEST-START | Shutdown
[task 2025-11-05T21:26:05.458+00:00] 21:26:05 INFO - Browser Chrome Test Summary
[task 2025-11-05T21:26:05.458+00:00] 21:26:05 INFO - Passed: 3566
[task 2025-11-05T21:26:05.459+00:00] 21:26:05 INFO - Failed: 1
[task 2025-11-05T21:26:05.459+00:00] 21:26:05 INFO - Todo: 3
[task 2025-11-05T21:26:05.459+00:00] 21:26:05 INFO - Mode: e10s
[task 2025-11-05T21:26:05.460+00:00] 21:26:05 INFO - *** End BrowserChrome Test Results ***
Updated•1 year ago
|
Comment 7•1 year ago
|
||
| bugherder | ||
Comment 8•1 year ago
|
||
firefox-release Uplift Approval Request
- User impact if declined: None, but the newtab team will not be able to reliably train-hop to the release channel, since older versions of activity-stream.bundle.js might be loaded from the ScriptPreloader cache.
- Code covered by automated testing: no
- Fix verified in Nightly: yes
- Needs manual QE test: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: We've changed how newtab loads its content scripts to skip the ScriptPreloader cache. The fact that it loads the scripts correctly and renders is proof that it's working.
- String changes made/needed: No.
- Is Android affected?: no
| Assignee | ||
Comment 9•1 year ago
|
||
This is a safe, upliftable change that gets us off of the ScriptPreloader. The next logical
step is to get rid of the noscript version of the activity-stream HTML page, and load the
scripts on the page "normally" with <script> tags. That will occur instead in bug 1998468.
Original Revision: https://phabricator.services.mozilla.com/D271425
Updated•1 year ago
|
Updated•1 year ago
|
Updated•1 year ago
|
Comment 10•1 year ago
|
||
| uplift | ||
| Assignee | ||
Updated•1 year ago
|
Description
•