More serialization between foreground/background
Repository details (talkie)
- Project page
- talkie
- Project log category
- talkie (708 entries)
- Repository
- @joelpurra/talkie
- Owner
- @joelpurra
- Issues
- Issues on Github
- Contributors
- Contributors on Github
- Project status
- ⏲️ This project has had recent commits.
- 📂 This project is open.
- 🌠 This project is popular.
- Repository activity period
- 🗓—
- Commits
- 751 commits
- Stars
- 72 stars
Commit details (eec9c455)
- Author
- Joel Purra
- Authored at
- Committer
- Joel Purra
- Committed at
Commit message
More serialization between foreground/background
- There has been an uptick in errors in Firefox with the message
can't access dead object
.
- Occurs when listing/configuring voices on the options page.
- A simple page reload can work around the problem, but it is not a permanent fix for a one-time problem.
- The error has been reported (via email) by three users in 2023.
- The error message is Firefox-specific, and the error does not seem to occur in Chromium-based browsers.
- Reports come from the options page, where it so happens that (optional, manual) prepared (email) error reports are available.
- If the error happens to be the background "process", the issue may be obscured since there is no automatic crash reporting. No background incidents have been reported.
- The error happens sporadically, and may be hard to reliably reproduce.
- Presumably triggered when one part of the web extension is unloaded, but another part still holds object/array references from the former.
- The the former part already being "gone", the error occurs in the latter.
- May be related to webext background page timeouts, as well as to how long the options page is open (but perhaps not actively accessing the background).
- Seems related to accessing
SafeVoiceObject
.
- The Talkie-specific object was previously introduced to avoid this particular issue, mirroring the browser-native
SpeechSynthesisVoice
objects.- The error occurs despite each
SafeVoiceObject
being a newly created object where all property values are primitives.- It may happen that newly
SafeVoiceObject
objects (orSafeVoiceObjects
arrays) themselves become the dead references. The underlying issue had been assumed to be restriced to browser-native objects, created outside the direct control of Talkie.- Documentation from Mozilla on this error is generally outdated
- Documention refers to the old type of "Firefox addons" (pre-webext), and suggested fixes cannot be applied.
- Talkie is a webext (not an old "addon"), although a bit older (using a background page) – not the most recent version (using services workers).
- The error still seem to belong to the same class of "dead object" reference/access/type errors.
- This fix attempts to reduce errors by applying additional serialization/deserialization.
- Serialization is performed using
JSON.stringify(...)
/JSON.parse(...)
.- Applied only to passing non-primitives (objects, arrays) between the foreground/background, meaning the Talkie "services" API.
- The extra serialization is performed after receiving objects/arrays from "another" webext part, such that the passed reference is short-lived and not returned to callers.
- An alternative fix is to only pass primitives, to hopefully avoid references.
- Objects/arrays may be passed as JSON-encoded strings in transit between "parts". May (already have been) be implemented generically, using a full "wire" protocol?
- Can also reduce object/array use in the Talkie service API, to avoid references.
- Passing webext-native
browser.Tab.Tab
objects has been avoided by only passing the tab identifier (Tab.Tab.id: number | undefined
). The object result was not used anyhow, as the opening tab does not communicate with the newly opened in Talkie.- The real fix may be to upgrade Talkie to webext manifest v3 (MV3).
- The services workers used in v3 should be better suited for messaging.
- An upgrade is required anyhow, since both Mozilla Firefox and Chromium (Google Chrome) will end v2 support.
Raw text
More serialization between foreground/background - There has been an uptick in errors in Firefox with the message `can't access dead object`. - Occurs when listing/configuring voices on the options page. - A simple page reload can work around the problem, but it is not a permanent fix for a one-time problem. - The error has been reported (via email) by three users in 2023. - The error message is Firefox-specific, and the error does not seem to occur in Chromium-based browsers. - Reports come from the options page, where it so happens that (optional, manual) prepared (email) error reports are available. - If the error happens to be the background "process", the issue may be obscured since there is no automatic crash reporting. No background incidents have been reported. - The error happens sporadically, and may be hard to reliably reproduce. - Presumably triggered when one part of the web extension is unloaded, but another part still holds object/array references from the former. - The the former part already being "gone", the error occurs in the latter. - May be related to webext background page timeouts, as well as to how long the options page is open (but perhaps not actively accessing the background). - Seems related to accessing `SafeVoiceObject`. - The Talkie-specific object was previously introduced to avoid this particular issue, mirroring the browser-native `SpeechSynthesisVoice` objects. - The error occurs despite each `SafeVoiceObject` being a newly created object where all property values are primitives. - It may happen that newly `SafeVoiceObject` objects (or `SafeVoiceObjects` arrays) themselves become the dead references. The underlying issue had been assumed to be restriced to browser-native objects, created outside the direct control of Talkie. - Documentation from Mozilla on this error is generally outdated - Documention refers to the old type of "Firefox addons" (pre-webext), and suggested fixes cannot be applied. - Talkie is a webext (not an old "addon"), although a bit older (using a background page) -- not the most recent version (using services workers). - The error still seem to belong to the same class of "dead object" reference/access/type errors. - This fix attempts to reduce errors by applying additional serialization/deserialization. - Serialization is performed using `JSON.stringify(...)`/`JSON.parse(...)`. - Applied only to passing non-primitives (objects, arrays) between the foreground/background, meaning the Talkie "services" API. - The extra serialization is performed _after receiving_ objects/arrays from "another" webext part, such that the passed reference is short-lived and not returned to callers. - An alternative fix is to only pass primitives, to hopefully avoid references. - Objects/arrays may be passed as JSON-encoded strings in transit between "parts". May (already have been) be implemented generically, using a full "wire" protocol? - Can also reduce object/array use in the Talkie service API, to avoid references. - Passing webext-native `browser.Tab.Tab` objects has been avoided by only passing the tab identifier (`Tab.Tab.id: number | undefined`). The object result was not used anyhow, as the opening tab does not communicate with the newly opened in Talkie. - The real fix may be to upgrade Talkie to webext manifest v3 (MV3). - The services workers used in v3 should be better suited for messaging. - An upgrade is required anyhow, since both Mozilla Firefox and Chromium (Google Chrome) will end v2 support.