mirror of https://github.com/vladmandic/human
workaround for chrome offscreencanvas bug
parent
12644a3e06
commit
02afd6c54f
|
@ -1,3 +1,4 @@
|
|||
node_modules
|
||||
pnpm-lock.yaml
|
||||
assets/tf*
|
||||
*.swp
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
|
||||
### **HEAD -> main** 2021/10/04 mandic00@live.com
|
||||
|
||||
|
||||
### **origin/main** 2021/10/03 mandic00@live.com
|
||||
|
||||
- add blazepose v2 and add annotations to body results
|
||||
- fix backend order initialization
|
||||
- added docker notes
|
||||
- breaking change: new similarity and match methods
|
||||
- release candidate
|
||||
|
|
|
@ -499,7 +499,7 @@ function runHumanDetect(input, canvas, timestamp) {
|
|||
return;
|
||||
}
|
||||
if (ui.hintsThread) clearInterval(ui.hintsThread);
|
||||
if (ui.useWorker) {
|
||||
if (ui.useWorker && human.env.offscreen) {
|
||||
// get image data from video as we cannot send html objects to webworker
|
||||
const offscreen = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(canvas.width, canvas.height) : document.createElement('canvas');
|
||||
offscreen.width = canvas.width;
|
||||
|
|
|
@ -66,14 +66,14 @@
|
|||
"@tensorflow/tfjs-layers": "^3.9.0",
|
||||
"@tensorflow/tfjs-node": "^3.9.0",
|
||||
"@tensorflow/tfjs-node-gpu": "^3.9.0",
|
||||
"@types/node": "^16.10.2",
|
||||
"@types/node": "^16.10.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
||||
"@typescript-eslint/parser": "^4.33.0",
|
||||
"@vladmandic/build": "^0.5.3",
|
||||
"@vladmandic/pilogger": "^0.3.3",
|
||||
"canvas": "^2.8.0",
|
||||
"dayjs": "^1.10.7",
|
||||
"esbuild": "^0.13.3",
|
||||
"esbuild": "^0.13.4",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-plugin-import": "^2.24.2",
|
||||
|
|
|
@ -24,6 +24,7 @@ export function canvas(width, height): HTMLCanvasElement | OffscreenCanvas {
|
|||
if (env.offscreen) {
|
||||
c = new OffscreenCanvas(width, height);
|
||||
} else {
|
||||
if (typeof document === 'undefined') throw new Error('attempted to run in web worker but offscreenCanvas is not supported');
|
||||
c = document.createElement('canvas');
|
||||
c.width = width;
|
||||
c.height = height;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as tf from '../../dist/tfjs.esm.js';
|
||||
import * as image from '../image/image';
|
||||
import { mergeDeep } from './util';
|
||||
import { mergeDeep, log } from './util';
|
||||
|
||||
export type Env = {
|
||||
browser: undefined | boolean,
|
||||
|
@ -129,8 +129,6 @@ export async function backendInfo() {
|
|||
export async function get() {
|
||||
env.browser = typeof navigator !== 'undefined';
|
||||
env.node = typeof process !== 'undefined';
|
||||
// @ts-ignore WorkerGlobalScope evaluated in browser only
|
||||
env.worker = env.browser ? (typeof WorkerGlobalScope !== 'undefined') : undefined;
|
||||
env.tfjs.version = tf.version_core;
|
||||
|
||||
// offscreencanvas supported?
|
||||
|
@ -144,11 +142,21 @@ export async function get() {
|
|||
env.agent = navigator.userAgent.replace(raw[0], '');
|
||||
if (env.platform[1]) env.agent = env.agent.replace(raw[1], '');
|
||||
env.agent = env.agent.replace(/ /g, ' ');
|
||||
|
||||
// chrome offscreencanvas gpu memory leak
|
||||
const isChrome = env.agent.match(/Chrome\/.[0-9]/g);
|
||||
const verChrome = isChrome && isChrome[0] ? isChrome[0].split('/')[1] : 0;
|
||||
if (verChrome > 0 && verChrome > 92 && verChrome < 96) {
|
||||
log('disabling offscreenCanvas due to browser error:', isChrome ? isChrome[0] : 'unknown');
|
||||
env.offscreen = false;
|
||||
}
|
||||
}
|
||||
} else if (typeof process !== 'undefined') {
|
||||
env.platform = `${process.platform} ${process.arch}`;
|
||||
env.agent = `NodeJS ${process.version}`;
|
||||
}
|
||||
// @ts-ignore WorkerGlobalScope evaluated in browser only
|
||||
env.worker = env.browser && env.offscreen ? (typeof WorkerGlobalScope !== 'undefined') : undefined;
|
||||
await backendInfo();
|
||||
|
||||
// get cpu info
|
||||
|
|
Loading…
Reference in New Issue