Reminder - no plan survives breakfast.
- Feel free to send pull requests to the repo!
- Here’s a contributing guide!
- Here’s the guide for creating pull requests that smurfd used and recommends!
Today
- Brought to you by HTTP Error Code 431!
- via keanu.codes
- Today will be a slightly shorter episode.
- No episode next week!
- Is it cleaner to just create a specialized protocol handler for cached newtab resources in this configuration?
```HTML
```
Add a moz-newtab-cached protocol handler that can run in the privileged about content process.
It's job will be to get a remote stream from the parent for script, or for styles.
When the parent receives the request, the parent will get the hash value from prefs.
Will retrieve the cache entry for the particular resource - like, moz-newtab-cached://script.js - and check that the hash matches the expectation. If not, blow away all caches, fallback to streaming out the packaged script.
After retrieving the stream, kick off a DeferredTask that will eventually kick a check to see
if we need to refresh the cache. Once that fires, check RemoteSettings to see if the hash and/or
version has changed.
If the hash and/or version has changed, download them and stream them into the cache:
Writing to the cache. When it's time to write to the cache:
- Recreate the entries for script and styles, and hold onto the new references.
- Write the new hash into prefs.
- Set the metadata to include the hash and version numbers.
- Begin streaming, this puts the entries into WRITING mode.
- Parallel stream scripts and styles into the cache output streams
- If either fail, doom the cache entry. Clear the pref value for the hash. Try again later.
moz-newtab-cached protocol has one job: get a remote stream from the parent that will either pull from the valid cache entry OR will fallback to the built-in one. Which means that we have a bit of separation here:
moz-newtab-cached protocol handler is the "read-only" parts here. It just knows how to read from the cache. It does not know how to write to it. It knows how to fall back.
The other part is the business around noticing that a newtab loaded, and kicking off the DeferredTask to maybe write an update to the cache.
Chat
- Join us in the Livehacking room on Mozilla’s Matrix instance! Here’s documentation on how to join. I’m only sorta monitoring the Twitch chat. A bot will try to bridge Matrix and Twitch (joc-bridgebot).
Links
- Nathan Baggs
- Felicia Bacon
- nbp hacks on the SpiderMonkey JS engine
- Alessandro Castellani has been streaming himself livehacking on Thunderbird
- emilio hacks on Firefox!
- Compiler Compiler - watch a Mozilla engineer hack on the SpiderMonkey JavaScript engine!
- How mconley uses Mercurial
- Andreas Kling hacks on a custom browser engine for a hand-rolled OS called SerenityOS
- The Joy of Coding: Community-Run Episode guide
- Feel free to send pull requests to the repo!
- Here’s the guide for creating pull requests that smurfd used and recommends!
- I've been mirroring the episodes to YouTube
- Code Therapy with Danny O’Brien
- Watch a developer put together a Windows game from scratch (no third-part engines) - really great explanations: https://handmadehero.org/
- /r/WatchPeopleCode for more livehacking!
Glossary
- BHR - “Background Hang Reporter”, a thing that records information about when Firefox performs poorly and sends it over Telemetry
- e10s ("ee ten ESS") - short for Electrolysis, which is the multi-process Firefox project
- CPOW ("ka-POW" or sometimes "SEE-pow") = Cross-Process Object Wrapper. See this blog post.
- Deserialize - "turn a serialized object back into the complex object”
- Serialize - "turn a complex object into something that can be represented as primitives, like strings, integers, etc
- Regression - something that made behaviour worse rather than better. Regress means to “go backward”, more or less.
- l10n - localization
- a11y - accessibility
- i18n - internationalization
- k8s - kubernetes
Feedback
- @mconley@mozilla.social on Mastodon
- @mike_conley on Twitter
- You can chat with me on Matrix at @mconley:mozilla.org
- mikeconley.ca/blog
- mconley at mozilla dot com