ffmpegwasm / ffmpeg.wasm

FFmpeg for browser, powered by WebAssembly
https://ffmpegwasm.netlify.app
MIT License
14.01k stars 816 forks source link

Error when using ffmpeg.wasm in Chrome for Android #506

Closed OZIOisgood closed 1 year ago

OZIOisgood commented 1 year ago

I am experiencing an error when using the ffmpeg.wasm library in an Angular web application. The issue occurs specifically in Chrome for Android (v.114) and does not occur on desktop or iPhone devices.


Steps to reproduce:

  1. Set Cross-Origin-Embedder-Policy and Cross-Origin-Opener-Policy headers in the application as follows:
    • "Cross-Origin-Embedder-Policy: require-corp"
    • "Cross-Origin-Opener-Policy: same-origin"
  2. Build and deploy the Angular application.
  3. Access the application using Chrome for Android (version 114).
  4. Perform the actions that trigger the ffmpeg.wasm library.

The project is wrapped into Docker container using NGINX. For production version headers are added to the nginx.conf

server {
    listen 80;
    root /usr/share/nginx/html;
    index index.html;
    server_name localhost;

    location / {
        try_files $uri $uri/ /index.html;
    }

    add_header Cross-Origin-Embedder-Policy 'require-corp';
    add_header Cross-Origin-Opener-Policy 'same-origin';
}

and for the development I am using headers in angular.json

"serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "headers": {
              "Cross-Origin-Embedder-Policy": "require-corp",
              "Cross-Origin-Opener-Policy": "same-origin"
            }
          },

Expected behavior:

The application should work as expected without any errors and the ffmpeg.wasm library should function properly.


Actual behavior:

When using the application in Chrome for Android, the following error message is displayed in the console: "

Uncaught (in promise): RangeError: WebAssembly.Memory(): could not allocate memory RangeError: WebAssembly.Memory(): could not allocate memory at blob:https://ffmpeg-wasm.staging.excelation.io/b0ca1e15-a542-4da7-8cbd-d2611387f4ae:22:82 at Object. (https://ffmpeg-wasm.staging.excelation.io/main.7375c6b0fb9d144b.js:1:5312) at Generator.next () at fe (https://ffmpeg-wasm.staging.excelation.io/main.7375c6b0fb9d144b.js:1:233316) at _e (https://ffmpeg-wasm.staging.excelation.io/main.7375c6b0fb9d144b.js:1:233548) at v.invoke (https://ffmpeg-wasm.staging.excelation.io/polyfills.ef33490f1a09416f.js:1:6560) at Object.onInvoke (https://ffmpeg-wasm.staging.excelation.io/main.7375c6b0fb9d144b.js:1:96935) at v.invoke (https://ffmpeg-> wasm.staging.excelation.io/polyfills.ef33490f1a09416f.js:1:6500) at M.run (https://ffmpeg-wasm.staging.excelation.io/polyfills.ef33490f1a09416f.js:1:1956) at https://ffmpeg-wasm.staging.excelation.io/polyfills.ef33490f1a09416f.js:1:16757

"


Testing environment:

Angular version: 14.0.3 ffmpeg.wasm version: @ffmpeg/core 0.11.0 and @ffmpeg/ffmpeg 0.11.6 Chrome for Android version: 114


Testing devices:


App Usage:


Additional information:


Please let me know if any further details or code examples are needed. Thank you!

Stan-2meu commented 1 year ago

This seems to have been an issue for years. Has anyone have figured to work around?

OZIOisgood commented 1 year ago

As we understood and tested, the problem is with the Google Chrome Mobile version. There are currently two latest versions of Chrome: 32 bit and 64 bit. If the user has an old phone (less than 8 gigabytes of RAM), then Play Market will download a 32 bit version that does not work with ffmpeg-wasm.

This does not apply to iPhones, because all browsers on IOS use webkit.