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

元素很多时 downloadFullImage 导出图片失败 #2980

Closed
ZENKI-CS opened this issue Jun 24, 2021 · 7 comments · Fixed by #3210
Closed

元素很多时 downloadFullImage 导出图片失败 #2980

ZENKI-CS opened this issue Jun 24, 2021 · 7 comments · Fixed by #3210

Comments

@ZENKI-CS
Copy link

1.如果是报错导致的下载失败,控制台会有以下信息:
Uncaught (in promise) RangeError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': Out of memory at ImageData creation

2.如果下载的图片无法打开,一般是因为 toDataURL 返回 的值 是 'data:,'

dataURL = canvasDom.toDataURL(type); 
@xgxm13
Copy link

xgxm13 commented Jun 30, 2021

1的问题有解决吗,我也遇到了,就是数据很多的情况下才有这个报错
image
image
g6.min.js?30d1:23未捕获范围错误:未能对“CanvasRenderingContext2D”执行“getImageData”:创建ImageData时内存不足

@Yanyan-Wang
Copy link
Contributor

数据量太大时导致 canvas API 调用内存不足。尝试先 fitView 再 download 呢

@xgxm13
Copy link

xgxm13 commented Jul 1, 2021

fitView

这个不行,但是我把画布缩小到一定比例不会报错了
graph.zoomTo(0.35, { x: 800, y: 100 });
这样搞也有坏处,就是下载的图不太清晰

@Yanyan-Wang
Copy link
Contributor

graph.getCanvasBBox() 打印看下有多大?

@ZENKI-CS
Copy link
Author

ZENKI-CS commented Jul 5, 2021

【最终发现了多种不同情况图片下载失败或异常】

情况一:
未能对“CanvasRenderingContext2D”执行“getImageData”:创建ImageData时内存不足(这种比较易懂)

情况二:
数据量大时也能下载图片,也没有【情况一】中的报错,但是下载的图片内容为空,断点查看是发现 G6 内部最终处理后的图片内容 居然返回了 'data:,'

情况三:
发现某些元素中含有 NaN 的值,导致下载不了图片,也没有任何报错,G6 内部也没有 警告日志

情况四:
数据量大时可以下载图片,但是会出现某些 node 节点【图标】会丢失,如果把zoom 改小,或者把图片质量降低,图片内容就不会有节点丢失

@ZENKI-CS
Copy link
Author

ZENKI-CS commented Jul 5, 2021

fitView

这个不行,但是我把画布缩小到一定比例不会报错了
graph.zoomTo(0.35, { x: 800, y: 100 });
这样搞也有坏处,就是下载的图不太清晰

fitView 没有用的

Yanyan-Wang pushed a commit that referenced this issue Sep 24, 2021
…node shouldEnd does not stop the dragging node behavior, closes: #3173; fix: drag-combo fails to merge combo with enableDelegate, closes: #3137; fix: uncombo does not trigger afterremoveitem event, closes: #3179; fix: error label background position when the edge label has position start, closes: #3129; fix: destroyed graph judgement, closes: #3203; fix: edge click event will not be triggered when the contextmenu is configure with trigger click, closes: #3201; feat: drag-combo with shouldEnd, closes: #3202; chore: information for failing to download image, closes: #2980;
Yanyan-Wang pushed a commit that referenced this issue Sep 24, 2021
…node shouldEnd does not stop the dragging node behavior, closes: #3173; fix: drag-combo fails to merge combo with enableDelegate, closes: #3137; fix: uncombo does not trigger afterremoveitem event, closes: #3179; fix: error label background position when the edge label has position start, closes: #3129; fix: destroyed graph judgement, closes: #3203; fix: edge click event will not be triggered when the contextmenu is configure with trigger click, closes: #3201; feat: drag-combo with shouldEnd, closes: #3202; chore: information for failing to download image, closes: #2980;
Yanyan-Wang pushed a commit that referenced this issue Sep 24, 2021
…node shouldEnd does not stop the dragging node behavior, closes: #3173; fix: drag-combo fails to merge combo with enableDelegate, closes: #3137; fix: uncombo does not trigger afterremoveitem event, closes: #3179; fix: error label background position when the edge label has position start, closes: #3129; fix: destroyed graph judgement, closes: #3203; fix: edge click event will not be triggered when the contextmenu is configure with trigger click, closes: #3201; feat: drag-combo with shouldEnd, closes: #3202; chore: information for failing to download image, closes: #2980;
@zyh0yh
Copy link

zyh0yh commented Sep 6, 2024

图片内容过多,导出的图片过大,都会导致导出的图片呈现空白的状态,这是因为在生成图片的时候,炸内存了,返回的base64 data 是空的,所以导致图片空白,建议切片导出,导出之后在拼接

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants