RFR: 8357714: AudioClip.play crash on macOS when loading resource from jar

Alexander Matveev almatvee at openjdk.org
Tue Jul 8 01:05:43 UTC 2025


On Fri, 4 Jul 2025 13:03:54 GMT, Johan Vos <jvos at openjdk.org> wrote:

>> modules/javafx.media/src/main/native/jfxmedia/platform/osx/avf/AVFMediaPlayer.mm line 806:
>> 
>>> 804: 
>>> 805:         NSMutableData* readData = nil;
>>> 806:         bool isRandomAccess = locatorStream->GetCallbacks()->IsRandomAccess();
>> 
>> `URIConnectionHolder` always return `false` for "jar" or "jrt" protocol. Why it was added?
>
> In case of jar, the ConnectionHolder is a `MemoryConnectionHolder` (because Locator already has a cacheEntry) which has true for isRandomAccess. 
> The cacheEntry is created by the `NativeMediaAudioClip<init>` which is indirectly called by the AudioClip constructor.
> 
> In case `readNextBlock` is used on a MemoryConnectionHolder, it seems all chuncks are asked  and played simultaneously (bug in MemoryConnectionHolder.readNextBlock?). With `readBlock` the order and sequence seem to be ok.
> 
> Alternatively, we might try to use the already-created ConnectionHolder instead of creating a new one in OSXMediaPlayer.mm.

Yes, you right `MemoryConnectionHolder` in case of jar, but only for AudioClip. MediaPlayer does not use it. I tested AudioClip with jar with and without random access. Without random access I only hear some clicking sounds, so looks like it does not work completely. With random access I can only hear audio for like 30 seconds and then it loops, so looks like it is broken as well.

Can you play audio file correctly via AudioClip?

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1839#discussion_r2191270417


More information about the openjfx-dev mailing list