Closed gqgs closed 3 years ago
- I'm submitting a ... [x] bug report [ ] feature request [ ] question about the decisions made in the repository [ ] question about how to use this project
This call breaks in browsers without OffscreenCanvas support. https://caniuse.com/offscreencanvas
It seems the script still works fine without the call to
tf_webgl.setWebGLContext
.
OffscreenCanvas can be used for Web worker background processing to avoid UI freezes. This is a new feature of newer browsers. I recommend upgrading the browser. Maybe I will try to add a compatibility check in a future version .
@HighCWu Thanks for the reply. A possible hotfix would be just checking if the browser has support in that section.
if (typeof OffscreenCanvas !== "undefined") {
const canvas = new OffscreenCanvas(320, 200);
let context = canvas.getContext('webgl2');
if (!context) {
context = canvas.getContext('webgl');
if (context)
tf_webgl.setWebGLContext(1, context);
}
else {
tf_webgl.setWebGLContext(2, context);
}
}
The UI will freeze if it is undetected but for now it might be better than the script not working at all. Unfortunately upgrading the browser it's not a option for a lot of people as you can see in the caniuse link above. Firefox, Safari and IE still don't support OffscreenCanvas in their latest versions.
@HighCWu Thanks for the reply. A possible hotfix would be just checking if the browser has support in that section.
if (typeof OffscreenCanvas !== "undefined") { const canvas = new OffscreenCanvas(320, 200); let context = canvas.getContext('webgl2'); if (!context) { context = canvas.getContext('webgl'); if (context) tf_webgl.setWebGLContext(1, context); } else { tf_webgl.setWebGLContext(2, context); } } The UI will freeze if it is undetected but for now it might be better than the script not working at all. Unfortunately upgrading the browser it's not a option for a lot of people as you can see in the caniuse link above. Firefox, Safari and IE still don't support OffscreenCanvas in their latest versions.
Thanks. I'll try it later.
cdbe616fadcc2a16c454c517d0fb961e8239bc74
https://github.com/HighCWu/waifu2x-tfjs/blob/2a31b376d5d2f43c9890d335251cce9259bd6828/src/lib/predictor.ts#L7
This call breaks in browsers without OffscreenCanvas support. https://caniuse.com/offscreencanvas
It seems the script still works fine without the call to
tf_webgl.setWebGLContext
.