Resources / MV3 Guide
Offscreen documents—safe usage patterns
Reach DOM/canvas/media APIs from MV3 without shipping hidden UI to users.
Good use cases
- Canvas/image processing
- Text-to-speech or other audio APIs
- Legacy browser APIs that require a document context
Lifecycle
- Justify reason (policy note) before creation.
- Create once, reuse, and close when done.
- Track an open count and add a watchdog to prevent leaks.
Messaging
- Define clear command types and contracts.
- Cap payload sizes; pass references or blobs sparingly.
- Handle cancellation and surface structured errors.
Pitfalls
- Leaving offscreen docs open indefinitely.
- Using them as a general background replacement.
- Leaking memory via long-lived handlers or large payloads.