music-metadata icon indicating copy to clipboard operation
music-metadata copied to clipboard

Safari parseBlob failure

Open bradleat opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

music-metadata version

10.2.0

Current Behavior

When parsing a blob with Safari, I get the following error:

TypeError: ReadableStreamBYOBReader needs a ReadableByteStreamController

Expected Behavior

No response

Attached audio sample?

  • [X] I have provided sufficient information to reproduce the issue

bradleat avatar Aug 20 '24 18:08 bradleat

I've tried using:

https://github.com/MattiasBuelens/web-streams-polyfill

It doesn't work.

bradleat avatar Aug 20 '24 18:08 bradleat

Do you have the same issue here using Safari?

A workaround is:


import {parseBuffer} from 'music-metadata';

let blob; // Assume this Blob is assigned

const metadata = await parseBuffer(await blob.bytes()), {mimeType: blob.type});

(I have not tested it)

Ref:

Borewit avatar Aug 20 '24 19:08 Borewit

Is there is any news, feel free to re-open

Borewit avatar Sep 03 '24 16:09 Borewit

Image

Yes, the issue occurs there as well. The proposed workaround works though, for what its worth.

jonluca avatar Jan 18 '25 04:01 jonluca

I will try to switch from BYOB (bring your own buffer)/byte stream to the default stream.

Ref: https://developer.mozilla.org/docs/Web/API/ReadableStream/ReadableStream

Borewit avatar Jan 18 '25 12:01 Borewit

@jonluca can please retry here: https://fallback-on-default-reader--audio-tag-analyzer.netlify.app/

Borewit avatar Jan 18 '25 18:01 Borewit

Image

Same issue

jonluca avatar Jan 19 '25 18:01 jonluca

Do you mind to try one more time @jonluca ? GUI should show v10.8.0-beta.3", otherwise please reload your browser.

Borewit avatar Jan 19 '25 18:01 Borewit

Image

New error this time haha

jonluca avatar Jan 19 '25 18:01 jonluca

Any improvement in music-metadata 10.8.1 deployed on https://github.com/Borewit/audio-tag-analyzer @jonluca ?

If you experience the same error, can you pinpoint where the out-of-bounds exception occurs?

Borewit avatar Jan 30 '25 14:01 Borewit

Image

Same issue

A way to debug might be to use bun -

import { parseBlob } from "music-metadata";
import { promises as fs } from "fs";

const data = await fs.readFile("~/Downloads/bohemian-rhapsody.mp3");
const blob = new Blob(data);
const metadata = await parseBlob(blob);
console.log(metadata);
bun test.mjs

Returns this exception

Image

jonluca avatar Jan 30 '25 20:01 jonluca

That was a pretty dumb attempt, as this is the the same TypeError error we had in the beginning. This TypeError should be caught to fallback on StreamDefaultReader.

You mind to try another time @jonluca, it may very very well now throw the Range out of bounds error. If you can please indicate where that occurs.

Borewit avatar Jan 31 '25 13:01 Borewit

I dont believe the site has an updated build - it's the same error as earlier.

However testing with main with bun seems to be working?

I've created a PR that adds a test suite for bun, since it uses JavaScriptCore under the hood, the same engine as Safari. There seems to be a timeout with webstreams in JSC in WavPack but otherwise seems fine.

https://github.com/Borewit/music-metadata/pull/2348

jonluca avatar Jan 31 '25 22:01 jonluca

I dont believe the site has an updated build - it's the same error as earlier.

I was convinced I merged the music-metadata v10.8.2, but apparently not. Now it is in via https://github.com/Borewit/audio-tag-analyzer/pull/1116.

Relevant change is: https://github.com/Borewit/peek-readable/pull/794/commits/21b34df5cc3fa14360d08158f5eb6871a9bd4e2b

I've created a PR that adds a test suite for bun, since it uses JavaScriptCore under the hood, the same engine as Safari. There seems to be a timeout with webstreams in JSC in WavPack but otherwise seems fine.

Awesome!

Borewit avatar Feb 01 '25 13:02 Borewit

Not sure if you folks are keeping the issue open for a specific reason, but tried the latest version of the library and Audio Tag Analyzer now and it works wonderfully!

Image

sleepyfran avatar Feb 12 '25 22:02 sleepyfran

Not sure if you folks are keeping the issue open for a specific reason, but tried the latest version of the library and Audio Tag Analyzer now and it works wonderfully!

Thanks for letting me know @sleepyfran, I did not know, and I am glad to hear it, as I spend many hours resolving this issue by implementing a dual Reader both, support BYOB and default, deep down in the dependency tree. But unable to test it myself with Safari.

Borewit avatar Feb 13 '25 07:02 Borewit