audio_metadata_reader icon indicating copy to clipboard operation
audio_metadata_reader copied to clipboard

Crashing on Samsung Devices

Open adeeteya opened this issue 11 months ago • 7 comments

The package works completely fine on version 0.0.5, upgrading to the latest version crashes (1.1.0). Tried the other versions but only 0.0.5 works.

Weirdly, the latest version only crashes on my physical Samsung phone and works fine with my pixel android emulator.

adeeteya avatar Jan 12 '25 11:01 adeeteya

Hi!

Would you have an error report? Something from your logs? There is a project called musicpod that uses the package without any bug on an Android device.

ClementBeal avatar Jan 12 '25 14:01 ClementBeal

The app just gets frozen. There is nothing printed on the console. I repeat that it works on my pixel emulator but does not work with my real physical Samsung S23 Ultra.

Version 0.0.5 works though. I tried other packages they seem to work fine as well the only issue is most of them are really slow and that's why I want to migrate to this package.

adeeteya avatar Jan 12 '25 14:01 adeeteya

Can you show your code? Maybe even a print that show the filenames. How many files are you reading?

ClementBeal avatar Jan 12 '25 14:01 ClementBeal

This is the snippet:-

late final AudioMetadata audioMetadata;

        String? thumbnailFilePath =
            _localAlbumArtCacheRepository.getCachedAlbumArtPath(filePath: path);

        //Cache album art if it doesn't exist
        if (thumbnailFilePath == null) {
          audioMetadata = readMetadata(File(path), getImage: true);
          if (audioMetadata.pictures.isNotEmpty) {
            thumbnailFilePath =
                await _localAlbumArtCacheRepository.cacheAlbumArt(
              filePath: path,
              bytes: audioMetadata.pictures[0].bytes,
            );
          }
        }

        //No need to fetch album art as it already exists
        else {
          audioMetadata = readMetadata(File(path));
        }

I am reading exactly 312 files. It does not print anything. The console freezes completely, it doesn't even print the usual logs which it otherwise does.

adeeteya avatar Jan 12 '25 15:01 adeeteya

Let's say that your business code is working correctly and the problem is from the package. Can you print the path of the path that make your app freeze? It might be a bug in the package.

When you have detected the file, please upload it here

ClementBeal avatar Jan 12 '25 15:01 ClementBeal

I think this attached file is causing the problem. After removing it seems to run but this did not happen with other packages problematic_mp3.zip

adeeteya avatar Jan 12 '25 15:01 adeeteya

Hi, I am also getting a hang when reading metadata from some mp3 files. It seems to happen when it encounters a zero length mp3 file or otherwise bad file. It seems to work on thousands of the other files I have.

try {
  final AudioMetadata metadata = readMetadata(File(track.filepath), getImage: true);
}

I can upload the file if that would help.

Update: Stepping thru the readMetadata code, it looks like it is an uncaught exception while opening the file. (track.openSync)

AudioMetadata readMetadata(File track, {bool getImage = false}) { final reader = track.openSync();

try { if (ID3v2Parser.canUserParser(reader)) { ....

rickc1588 avatar Jan 16 '25 04:01 rickc1588