JorenSix / Panako

The Panako acoustic fingerprinting system.
GNU Affero General Public License v3.0
179 stars 35 forks source link

Main thread hangs in java.io.FileInputStream.readBytes #41

Closed SalomonBrys closed 1 year ago

SalomonBrys commented 1 year ago

Panako can succesfully store all my MP3 collection, except a few MP3 files (that are perfectly playable) that makes it hang forever. Here one of the MP3 files in question : https://mega.nz/file/pKFVDAyb#vtjUcy2UfDPt5SJMl7HFTRsnZxFC3vRG_Cqyo0w8fGE

[0] % panako store "Blondie - Maria.mp3"
Audiofile;Audio duration;Fingerprinting duration;ratio

I've extracted the main thread stacktrace with Mission Control:

main [1] (RUNNABLE)
   java.io.FileInputStream.readBytes line: not available [native method]
   java.io.FileInputStream.read line: 276 
   java.io.BufferedInputStream.read1 line: 282 
   java.io.BufferedInputStream.read line: 343 
   java.io.BufferedInputStream.fill line: 244 
   java.io.BufferedInputStream.read1 line: 284 
   java.io.BufferedInputStream.read line: 343 
   be.tarsos.dsp.io.UniversalAudioInputStream.read line: 54 
   be.tarsos.dsp.AudioDispatcher.readNextAudioBlock line: 399 
   be.tarsos.dsp.AudioDispatcher.run line: 286 
   be.panako.strategy.olaf.OlafStrategy.toFingerprints line: 212 
   be.panako.strategy.olaf.OlafStrategy.toFingerprints line: 167 
   be.panako.strategy.olaf.OlafStrategy.store line: 97 
   be.panako.cli.Store$StoreTask.run line: 128 
   be.panako.cli.Store.run line: 74 
   be.panako.cli.Panako.actuallyReallyStartApplication line: 234 
   be.panako.cli.Panako.actuallyStartApplication line: 213 
   be.panako.cli.Panako.startApplication line: 155 
   be.panako.cli.Panako.main line: 329 

The same freeze (in java.io.FileInputStream.readBytes) is happening with panako print "Blondie - Maria.mp3".

Some informations about my machine:

salomonbrys@Salomons-MacBook-Pro ‹ master › : ~/Code/clones/Panako
[0] % uname -a
Darwin Salomons-MacBook-Pro.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct  9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64 x86_64 i386 Darwin

salomonbrys@Salomons-MacBook-Pro ‹ master › : ~/Code/clones/Panako
[0] % git show-ref HEAD
c2cd1cfe2305d1c933e7753a6823d2df4fb0c469 refs/remotes/origin/HEAD

salomonbrys@Salomons-MacBook-Pro ‹ master › : ~/Code/clones/Panako
[0] % java -version
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment Temurin-17.0.3+7 (build 17.0.3+7)
OpenJDK 64-Bit Server VM Temurin-17.0.3+7 (build 17.0.3+7, mixed mode, sharing)
SalomonBrys commented 1 year ago

So, it looks like it's an FFMPEG handling problem. Looks like the ffmpeg process never completes.

I can see it:

[130] % ps aux | grep ffmpeg
salomonbrys      57759   0.0  0.0 34681224  11468 s000  S+   12:45PM   0:00.19 ffmpeg -ss 0.0 -i /Users/salomonbrys/Downloads/Blondie - Maria.mp3 -vn -ar 16000 -ac 1 -sample_fmt s16 -f s16le pipe:1

If I kill the process (in this instance kill -9 57759), then panako completes succefully.

However, when I run this command manually, it completes correctly, so it looks like it's an issue of the process management by Panako / the JVM.

SalomonBrys commented 1 year ago

This issue is fixed by https://github.com/JorenSix/TarsosDSP/pull/212

JorenSix commented 1 year ago

Thanks for the bug report. I have updated the TarsosDSP dependency, using the maven package which should fix this problem. Thanks again for digging and reporting this issue!