@stream-io/video-filters-web 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs.js +16 -6
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +16 -6
- package/dist/index.es.js.map +1 -1
- package/dist/src/compatibility.d.ts +12 -1
- package/package.json +2 -1
- package/src/compatibility.ts +27 -2
- package/src/createRenderer.ts +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.2.2](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-filters-web-0.2.1...@stream-io/video-filters-web-0.2.2) (2025-09-17)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **video-filters:** prevent background tab throttling ([#1920](https://github.com/GetStream/stream-video-js/issues/1920)) ([f93d5cc](https://github.com/GetStream/stream-video-js/commit/f93d5cc5785957c7f181fcaf689ec366df9e646b))
|
|
10
|
+
|
|
5
11
|
## [0.2.1](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-filters-web-0.2.0...@stream-io/video-filters-web-0.2.1) (2025-05-15)
|
|
6
12
|
|
|
7
13
|
### Bug Fixes
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var wasmFeatureDetect = require('wasm-feature-detect');
|
|
4
|
+
var workerTimer = require('@stream-io/worker-timer');
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Checks if the current platform is a mobile device.
|
|
@@ -9,14 +10,21 @@ var wasmFeatureDetect = require('wasm-feature-detect');
|
|
|
9
10
|
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
|
|
10
11
|
*/
|
|
11
12
|
const isMobile = () => /Mobi/i.test(navigator.userAgent);
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether the current browser is Safari.
|
|
15
|
+
*/
|
|
16
|
+
const isSafari = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
12
17
|
/**
|
|
13
18
|
* Runs a check to see if the current platform supports
|
|
14
19
|
* the necessary APIs required for the video filters.
|
|
15
20
|
*/
|
|
16
|
-
const isPlatformSupported = async () => typeof document !== 'undefined' &&
|
|
21
|
+
const isPlatformSupported = async ({ forceMobileSupport = false, forceSafariSupport = false, } = {}) => typeof document !== 'undefined' &&
|
|
17
22
|
typeof window !== 'undefined' &&
|
|
18
23
|
typeof navigator !== 'undefined' &&
|
|
19
|
-
|
|
24
|
+
// we don't support mobile devices yet due to performance issues
|
|
25
|
+
(forceMobileSupport || !isMobile()) &&
|
|
26
|
+
// Safari has issues with timer throttling, causing low FPS when the tab goes to the background
|
|
27
|
+
(forceSafariSupport || !isSafari()) &&
|
|
20
28
|
typeof WebAssembly !== 'undefined' &&
|
|
21
29
|
!!window.WebGL2RenderingContext && // WebGL2 is required for the video filters
|
|
22
30
|
!!document.createElement('canvas').getContext('webgl2') &&
|
|
@@ -788,7 +796,8 @@ function createRenderer(tflite, videoSource, targetCanvas, options, onError) {
|
|
|
788
796
|
throw new Error(`backgroundImage element is required when backgroundFilter is image`);
|
|
789
797
|
}
|
|
790
798
|
const pipeline = buildWebGL2Pipeline(videoSource, backgroundImage, backgroundBlurLevel, backgroundFilter, targetCanvas, tflite, getSegmentationParams(segmentationLevel));
|
|
791
|
-
const
|
|
799
|
+
const timers = new workerTimer.WorkerTimer({ useWorker: true });
|
|
800
|
+
const id = timers.setInterval(() => {
|
|
792
801
|
try {
|
|
793
802
|
pipeline.render();
|
|
794
803
|
if (backgroundFilter === 'image') {
|
|
@@ -798,11 +807,12 @@ function createRenderer(tflite, videoSource, targetCanvas, options, onError) {
|
|
|
798
807
|
catch (error) {
|
|
799
808
|
onError?.(error);
|
|
800
809
|
}
|
|
801
|
-
}, 1000 / (fps <= 0 ? 30 : fps));
|
|
810
|
+
}, Math.floor(1000 / (fps <= 0 ? 30 : fps)));
|
|
802
811
|
return {
|
|
803
812
|
dispose: () => {
|
|
804
813
|
pipeline.cleanUp();
|
|
805
|
-
clearInterval(id);
|
|
814
|
+
timers.clearInterval(id);
|
|
815
|
+
timers.destroy();
|
|
806
816
|
},
|
|
807
817
|
};
|
|
808
818
|
}
|
|
@@ -1533,7 +1543,7 @@ const createTFLiteSIMDModule = (__Module) => {
|
|
|
1533
1543
|
return __Module.ready;
|
|
1534
1544
|
};
|
|
1535
1545
|
|
|
1536
|
-
const version = "0.2.
|
|
1546
|
+
const version = "0.2.2";
|
|
1537
1547
|
const packageName = "@stream-io/video-filters-web";
|
|
1538
1548
|
|
|
1539
1549
|
// @ts-expect-error - module is not declared
|