简体   繁体   English

在 chrome 中加载大图像时出现“Aw Snap”错误

[英]“Aw Snap” error when loading large image in chrome

I am trying to load an image from a server.我正在尝试从服务器加载图像。

The image is dynamically created on the server, which then passes the name [including the relative path] to the client for loading into a canvas.图像在服务器上动态创建,然后将名称 [包括相对路径] 传递给客户端以加载到画布中。

There are 3 layers of canvas, setting the same size of image and loading image to one canvas.有3层画布,设置相同大小的图像并将图像加载到一个画布上。

Everything working fine for small images.对于小图像,一切正常。 But for big images, [assuming above 9000 x 7000 px] it throws “Aw Snap” blue screen error.但是对于大图像,[假设高于 9000 x 7000 像素] 它会引发“Aw Snap”蓝屏错误。 Sometimes it managed to load the image but throw “Aw Snap” error by moving the mouse over the canvas, moving scroll bars or drawing a line over it.有时它设法加载图像,但通过将鼠标移动到画布上、移动滚动条或在其上画一条线来抛出“Aw Snap”错误。

I increased --disk-cache-size but didn't help.我增加了 --disk-cache-size 但没有帮助。

Even Setting these values didn't help [ --disable-accelerated-2d-canvas, --blacklist-accelerated-compositing, --blacklist-webgl, --disable-accelerated-compositing, --disable-accelerated-layers]即使设置这些值也无济于事 [ --disable-accelerated-2d-canvas, --blacklist-accelerated-compositing, --blacklist-webgl, --disable-accelerated-compositing, --disable-accelerated-layers]

Tested with IE and Safari - working fine but some delays.用 IE 和 Safari 测试 - 工作正常,但有些延迟。

Post your thoughts and hints.发表你的想法和提示。 Any help is appreciated.任何帮助表示赞赏。

Here is my code这是我的代码

function LoadImage(imageUrl) {
    try {
        var image_View = document.getElementById("imageView");
        var image_Temp = document.getElementById("imageTemp");
        var image_Tempt = document.getElementById("imageTempt");
        var ctx = image_View.getContext("2d");

        var img = new Image();
        img.onerror = function() {
            alert('The image could not be loaded.');
        }
        img.onload = function() {
            image_View.width = img.width;
            image_View.height = img.height;
            image_Temp.width = img.width;
            image_Temp.height = img.height;
            image_Tempt.width = img.width;
            image_Tempt.height = img.height;

            ctx.clearRect(0, 0, image_View.width, image_View.height);
            ctx.drawImage(img, 1, 1, img.width, img.height);
        }

        img.src = imageUrl;
    }
    catch (err) {
        alert(err.message);
    }
}

"Aw Snap" means that the OS killed the Chrome process for this tab. “Aw Snap”意味着操作系统终止了此选项卡的 Chrome 进程。 This happens when your OS thinks that Chrome did something wrong (like when it allocates too much memory, memory corruption, outdated shared libraries after a system patch).当您的操作系统认为 Chrome 做错了(例如分配过多内存、内存损坏、系统补丁后共享库过时)时,就会发生这种情况。

It's possible that Chrome needs too much memory to display such huge images. Chrome 可能需要太多内存才能显示如此巨大的图像。 The workaround would be to cut the images into pieces ("tiling") and just display those tiles which are visible on the screen.解决方法是将图像切成碎片(“平铺”),然后只显示在屏幕上可见的那些平铺。

To find out for sure, you can run Chrome from the command line.要确定,您可以从命令行运行 Chrome。 Sometimes, it prints more descriptive error messages on the console when part of it crashes.有时,当部分崩溃时,它会在控制台上打印更多描述性错误消息。

You should also try to apply the latest (security) patches to your OS, get the latest Chrome and reboot to make sure it's not a glitch.您还应该尝试将最新的(安全)补丁应用于您的操作系统,获取最新的 Chrome 并重新启动以确保它不是故障。 On my computer (16GB RAM, 1GB Video RAM), I can open a 19'000x19'000 PNG image without an error, it just takes ~20 seconds for the frame to render it.在我的电脑(16GB 内存,1GB 视频内存)上,我可以打开一个 19'000x19'000 的 PNG 图像而不会出错,帧渲染它只需要大约 20 秒。

You can debug "Aw Snap" errors enabling Chrome's logging .您可以调试启用Chrome 日志记录的“Aw Snap”错误。

To enable, launch Chrome using these command line flags:要启用,请使用以下命令行标志启动 Chrome:

--enable-logging --v=1

And open the Chrome's user data directory to find the file.并打开Chrome 的用户数据目录找到该文件。

Go to the property of google chrome shortcut add --no-sandbox to the end of the target field then click apply转到 google chrome 快捷方式的属性将--no-sandbox添加到目标字段的末尾,然后单击应用

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM