gpu.js
gpu.js copied to clipboard
There are too many active WebGL contexts on this page
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.
Maybe this can help? https://github.com/greggman/virtual-webgl
Create a new canavs,then make every process use the same canvas.