ffmpegwasm / ffmpeg.wasm

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

Can't load ffmpeg-core on iPhone 13 #590

Closed HendrikYtt closed 9 months ago

HendrikYtt commented 9 months ago

Describe the bug When trying to load ffmpeg-core in a React application on iPhone 13, it is unable to do so. But it is working just fine on desktop.

To Reproduce Running the following code on iPhone 13 in Safari or Edge results in an error:

import React, { useEffect, useRef } from 'react';

const ffmpegRef = useRef(new FFmpeg());

useEffect(() => {
        load();
}, []);

const load = async () => {
        try {
            const baseURL = 'https://unpkg.com/@ffmpeg/core@0.12.2/dist/umd';
            const ffmpeg = ffmpegRef.current;
            const coreURL = await toBlobURL(`${baseURL}/ffmpeg-core.js`, 'text/javascript');
            const wasmURL = await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, 'application/wasm');
            await ffmpeg.load({ coreURL, wasmURL });
        } catch (error) {
            console.log(error);
        }
};

Error: RuntimeError: Aborted(CompileError: WebAssembly.Module doesn't parse at byte 3: can't get Function local's type in group 0, in function at index 11). Build with - sASSERTIONS for more info.

Expected behavior Should load ffmpeg-core successfully.

Desktop (please complete the following information):

Smartphone (please complete the following information):

thexeos commented 9 months ago

We are also seeing this behavior. It also happens on earlier versions of iOS and on other device models.

I've noticed that it loads WASM file twice (versus just once on platforms where it works):

image

image

thexeos commented 9 months ago

Never mind. That's just the fallback logic of this package. When instantiateAsync fails to run, instantiateArrayBuffer is called to try again.

The other errors I've seen are:

thexeos commented 9 months ago

I've decided to test with a few more devices, here's what I've got:

iPhone 15 v17.0 - works iPhone 15 Pro v17.0 - works iPhone 14 v16.4 - works iPhone 14 Pro v16.3 - breaks iPhone 14 Plus v16.0 - breaks iPhone 13 v17.0 - works iPhone 13 v16.3 - breaks iPhone 13 Pro v15.6 - breaks

So it seems that whatever bug was causing this, it was fixed in 16.4 (which came out on March 27, 2023).

I couldn't find anything on WebKit Bugzilla that was fixed that recently under WebAssembly category.

HendrikYtt commented 9 months ago

Yes, it seems like updating OS fixes the issue.

tini2n commented 5 months ago

The same here. Might be workaround for this, not just updating browser...

YolineWu commented 5 months ago

We are also seeing this behavior. It also happens on earlier versions of iOS and on other device models.

I've noticed that it loads WASM file twice (versus just once on platforms where it works):

image

image

The same, download twice:

import coreURL from '../../node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.js?url'
import wasmURL from '../../node_modules/@ffmpeg/core/dist/esm/ffmpeg-core.wasm?url'
const ffmpeg = new FFmpeg()
ffmpeg.load({ coreURL, wasmURL })
nica0012 commented 1 month ago

I'm experiencing this issue as well on my iphone 13 pro max (ios 17.4)