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

docs: add warning for webgl cloning with preserveDrawingBuffer=false #2661

Merged
merged 1 commit into from
Aug 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/dom/document-cloner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class DocumentCloner {
img.src = canvas.toDataURL();
return img;
} catch (e) {
this.context.logger.info(`Unable to clone canvas contents, canvas is tainted`);
this.context.logger.info(`Unable to inline canvas contents, canvas is tainted`, canvas);
}
}

Expand All @@ -209,12 +209,23 @@ export class DocumentCloner {
if (!this.options.allowTaint && ctx) {
clonedCtx.putImageData(ctx.getImageData(0, 0, canvas.width, canvas.height), 0, 0);
} else {
const gl = canvas.getContext('webgl2') ?? canvas.getContext('webgl');
if (gl) {
const attribs = gl.getContextAttributes();
if (attribs?.preserveDrawingBuffer === false) {
this.context.logger.warn(
'Unable to clone WebGL context as it has preserveDrawingBuffer=false',
canvas
);
}
}

clonedCtx.drawImage(canvas, 0, 0);
}
}
return clonedCanvas;
} catch (e) {
this.context.logger.info(`Unable to clone canvas as it is tainted`);
this.context.logger.info(`Unable to clone canvas as it is tainted`, canvas);
}

return clonedCanvas;
Expand Down