8357714: AudioClip.play crash on macOS when loading resource from jar#1839
8357714: AudioClip.play crash on macOS when loading resource from jar#1839johanvos wants to merge 3 commits intoopenjdk:masterfrom
Conversation
In case of random access datasource, use readBlock instead of readNextBlock
|
👋 Welcome back jvos! A progress list of the required criteria for merging this PR into |
|
@johanvos This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 2 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
|
@sashamatveev can you review this? |
|
/reviewers 2 |
|
@andy-goryachev-oracle |
| unsigned int blockSize = locatorStream->GetCallbacks()->ReadNextBlock(); | ||
| unsigned int blockSize = -1; | ||
| if (isRandomAccess) { | ||
| blockSize = locatorStream->GetCallbacks()->ReadBlock(pos, size); |
There was a problem hiding this comment.
would it make sense to declare a local variable for locatorStream->GetCallbacks() ?
or do we assume the compiler is smart enough to do that?
There was a problem hiding this comment.
Not sure, but do not see a need from performance point view.
|
Would it be possible to come up with a system test? |
modules/javafx.media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.mm
Outdated
Show resolved
Hide resolved
modules/javafx.media/src/main/native/jfxmedia/platform/osx/avf/AVFMediaPlayer.mm
Show resolved
Hide resolved
| unsigned int blockSize = locatorStream->GetCallbacks()->ReadNextBlock(); | ||
| unsigned int blockSize = -1; | ||
| if (isRandomAccess) { | ||
| blockSize = locatorStream->GetCallbacks()->ReadBlock(pos, size); |
There was a problem hiding this comment.
Not sure, but do not see a need from performance point view.
|
Looks good overall.
|
|
Add null checks Fix errors in position and length calculations
|
@sashamatveev Thanks a lot. That all makes sense, and it seems to work indeed with the corrected position/length calculations. |
| CJavaInputStreamCallbacks *callbacks = new (nothrow) CJavaInputStreamCallbacks(); | ||
| if (callbacks == NULL) { | ||
| jobject jConnectionHolder = CLocator::CreateConnectionHolder(env, jLocator); | ||
| if (callbacks == NULL || jConnectionHolder == NULL) { |
There was a problem hiding this comment.
Extra space after callbacks == NULL.
It would be great to have a system test, but we currently have no framework for testing media in the system tests. It would be good to create this, but I expect it to be lots of work (dealing with native code and different frameworks based on platform), so I think it's better in a separate issue |
Correct. We do not have such a framework, and it would be out of scope for this issue. |
|
Got a reproducer for you: added AudioClip page to the Monkey Tester Build a jar and run it. Select AudioClip page, then pressing "Play XX" button would play .wav or .mp3 file from the said jar. edit: it works! |
|
Unrelated to this PR:
I'll create a separate ticket later. |
|
My apologies - forgot to build with The fixed code plays .mp3 from a jar without crashing. |
andy-goryachev-oracle
left a comment
There was a problem hiding this comment.
- the fix works with jdk23 or jdk24.
- native code changes look ok to me
|
Should we test with other audio formats, or everything is piped through the same code path? |
I tested with all supported formats. |
|
/integrate |
|
Going to push as commit 203c049.
Your commit was automatically rebased without conflicts. |
After JDK-8287822 (https://bugs.openjdk.org/browse/JDK-8287822), mpeg file content is no longer played via GSTPlatform but via OSXPlatform.
We need to correctly handle data in case the source is a file inside a jar, in which case CJavaInputStreamCallbacks is used.
The 2 changes I made are:
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1839/head:pull/1839$ git checkout pull/1839Update a local copy of the PR:
$ git checkout pull/1839$ git pull https://git.openjdk.org/jfx.git pull/1839/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 1839View PR using the GUI difftool:
$ git pr show -t 1839Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1839.diff
Using Webrev
Link to Webrev Comment