gpu.js icon indicating copy to clipboard operation
gpu.js copied to clipboard

There are too many active WebGL contexts on this page

Open caracal7 opened this issue 4 years ago • 2 comments

A GIF or MEME to give some spice of the internet

What is wrong?

Error "There are too many active WebGL contexts on this page, the oldest context will be lost." in console while application dynamically create gpu.js instances.

Where does it happen?

Its shown as error in Safari and as warning in Chrome

How do we replicate the issue?

<html>
<head>
    <script src="gpu-browser.js"></script>
</head>
<body>
    <script>

        for(let i = 0; i < 20; i++) {
            const gpu = new GPU();

            const kernel = gpu.createKernel(function(x) {
                return x;
            }).setOutput([1]);

            console.log(i, kernel(42));

            kernel.destroy();
            gpu.destroy();
        };

    </script>
</body>
</html>

How important is this (1-5)?

2

Expected behavior (i.e. solution)

No errors in console. No possible memory leaks

Other Comments

Maybe I need to use only one instance of GPU.js across the app? But I think this is not a good.

caracal7 avatar Nov 13 '21 18:11 caracal7

Maybe this can help? https://github.com/greggman/virtual-webgl

caracal7 avatar Nov 13 '21 18:11 caracal7

Create a new canavs,then make every process use the same canvas.

thesunfei avatar Feb 14 '22 08:02 thesunfei