codeant-ai-for-open-source[bot] commented on code in PR #44529:
URL: https://github.com/apache/superset/pull/44529#discussion_r4085210012
##########
superset-frontend/src/utils/downloadAsImage.tsx:
##########
@@ -559,14 +571,36 @@ export default function downloadAsImageOptimized(
}),
};
- const dataUrl = isPng
- ? await domToImage.toPng(agRootWrapper, agImageOptions)
- : await domToImage.toJpeg(agRootWrapper, agImageOptions);
+ let dataUrl: string;
+ if (isSafari()) {
+ // `dom-to-image-more` relies on SVG <foreignObject>, which WebKit
does
+ // not reliably paint. Keep the ag-grid preparation above, then use a
+ // DOM painter for the actual Safari capture.
+ const { default: html2canvas } = await import('html2canvas');
+ const canvas = await html2canvas(agRootWrapper, {
+ backgroundColor:
+ bgcolor === TRANSPARENT_RGBA ? null : (bgcolor ?? null),
+ height: imageHeight,
+ width: originalWidth,
+ scale,
+ useCORS: true,
Review Comment:
**Suggestion:** html2canvas attempts cross-origin images with CORS. Images
whose servers lack CORS headers are omitted, so Safari exports containing
external images become incomplete.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Possible bug`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=6bbe7349f8e94b7fbae87df108e666a1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=6bbe7349f8e94b7fbae87df108e666a1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/utils/downloadAsImage.tsx
**Line:** 586:586
**Comment:**
*Possible Bug: html2canvas attempts cross-origin images with CORS.
Images whose servers lack CORS headers are omitted, so Safari exports
containing external images become incomplete.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44529&comment_hash=94148b45c53ea685197489e74b6b6bb41aac82d3e2648928ab42d852c6775f45&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44529&comment_hash=94148b45c53ea685197489e74b6b6bb41aac82d3e2648928ab42d852c6775f45&reaction=dislike'>๐</a>
##########
superset-frontend/src/utils/downloadAsImage.tsx:
##########
@@ -612,6 +646,36 @@ export default function downloadAsImageOptimized(
}
try {
+ if (isSafari()) {
+ // `dom-to-image-more` serializes through SVG <foreignObject>, which
+ // WebKit does not reliably paint. html2canvas clones the document
itself;
+ // restore the clone-path canvas and visibility work in its clone
callback.
+ const { default: html2canvas } = await import('html2canvas');
+ const canvas = await html2canvas(elementToPrint as HTMLElement, {
+ backgroundColor:
+ bgcolor === TRANSPARENT_RGBA ? null : (bgcolor ?? null),
+ height: (elementToPrint as HTMLElement).scrollHeight,
+ width: (elementToPrint as HTMLElement).scrollWidth,
+ scale,
+ useCORS: true,
+ logging: false,
+ ignoreElements: element => !filter(element),
+ onclone: (_document, clone) => {
+ processCloneForVisibility(clone, isDashboardCapture);
+ preserveCanvasContent(elementToPrint, clone, getInstanceByDom);
Review Comment:
**Suggestion:** The capture dimensions are measured before
`processCloneForVisibility` expands clipped content, so expanded tables or
virtualized elements can be truncated by the stale `height` and `width` values.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Sometimes` ยท ๐ท๏ธ `Logic error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=536de22957fe4866bc870fd531c066f8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=536de22957fe4866bc870fd531c066f8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/utils/downloadAsImage.tsx
**Line:** 657:665
**Comment:**
*Logic Error: The capture dimensions are measured before
`processCloneForVisibility` expands clipped content, so expanded tables or
virtualized elements can be truncated by the stale `height` and `width` values.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44529&comment_hash=ecbe2bc460b09e8354012cd894d64d924cfd9e3d8084a3fe64a2664256db2919&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44529&comment_hash=ecbe2bc460b09e8354012cd894d64d924cfd9e3d8084a3fe64a2664256db2919&reaction=dislike'>๐</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]