Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: Can't find variable: OffscreenCanvas. ReferenceError: Can't find variable: document. #101

Open
7 tasks done
Talb2005 opened this issue Jan 22, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Talb2005
Copy link

Talb2005 commented Jan 22, 2025

  • I have verified that the issue occurs with the latest twilio-video-processors.js release and is not marked as a known issue in the CHANGELOG.md.
  • I reviewed the Common Issues and open GitHub issues and verified that this report represents a potentially new issue.
  • I am not sharing any Personally Identifiable Information (PII)
    or sensitive account information (API keys, credentials, etc.) when reporting this issue.

Our Sentry logs show that multiple users are encountering the following errors when using @twilio/video-processors version 3.0.0.

  • ReferenceError: Can't find variable: OffscreenCanvas
  • ReferenceError: Can't find variable: document

The ReferenceError: Can't find variable: OffscreenCanvas occurs when instantiating the BackgroundProcessor in:

@twilio/video-processors/lib/processors/background/BackgroundProcessor.ts in BackgroundProcessor at line 84:61
private readonly _inputFrameCanvas: OffscreenCanvas = new OffscreenCanvas(1, 1);

The ReferenceError: Can't find variable: document occur in twilio-virtual-background-processor-pipeline-worker.js and twilio-gaussian-blur-background-processor-pipeline-worker.js in:

function getCanvas() {
    return typeof OffscreenCanvas !== 'undefined' ? new OffscreenCanvas(1, 1) : document.createElement('canvas');
}

We are using the const isSupported from '@twilio/video-processors' to prevent non-supported browsers from using this feature, so these user agents are supposed to be supported.

  • On macOS, the errors occur on Safari <= 16.3.
  • On iPad, the errors occur on iOS / iPadOS <=16.3.1

This is probably related to the fact that Safari started supporting OffscreenCanvas only in version 16.4.

If document.createElement('canvas'); is called from within a web worker, then the document won't be available, hence the ReferenceError: Can't find variable: document

  • Browser(s): Safari <=16.3, any browser using WebKIT while iOS <=16.3.1.
  • Operating System: macOS - Safari <=16.3, iOS / iPadOS <=16.3.1
  • twilio-video-processors.js: 3.0.0
  • Third-party libraries (e.g., Angular, React, etc.): Angular
@Talb2005 Talb2005 added the bug Something isn't working label Jan 22, 2025
@Talb2005 Talb2005 changed the title ReferenceError: Can't find variable: OffscreenCanvas and ReferenceError: Can't find variable: document ReferenceError: Can't find variable: OffscreenCanvas. ReferenceError: Can't find variable: document. Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant