phoboslab / jsmpeg

MPEG1 Video Decoder in JavaScript
MIT License
6.31k stars 1.43k forks source link

Uncaught TypeError: Cannot perform %TypedArray%.prototype.set #366

Closed baur closed 3 years ago

baur commented 3 years ago

To Reproduce Steps to reproduce the behavior: Show more than 10 camera (simultaneously) and click F5 2,3-times

Desktop (please complete the following information):

image

baur commented 3 years ago

image

baur commented 3 years ago

I'm noticed it depends on chrome version, in latest version this error appears less than on old versions

phoboslab commented 3 years ago

Seems to be related to the WASM decoder. You can try to disable WASM in the constructor options. This comes with a performance hit, though:

var player = new JSMpeg.Player('file.ts', {
    disableWebAssembly: true
});

This explains the problem: https://stackoverflow.com/a/51663772

When there are many streams the Browser essentially has to realloc() the memory space for the WASM decoder. Calling WASM.prototype.createHeapViews() whenever that happens should fix the problem. I'm not sure how to properly detect when this happens though.

Another workaround, as stated in the Stackoverflow answer: create the WASM Module with a larger initial memory size here.

baur commented 3 years ago
var player = new JSMpeg.Player('file.ts', {
    disableWebAssembly: true
});

yes, it helped me! thank you!