corretto / corretto-8

Amazon Corretto 8 is a no-cost, multi-platform, production-ready distribution of OpenJDK 8
GNU General Public License v2.0
2.11k stars 221 forks source link

AudioUnit returns access denied on 8u302 but not 8u292 #332

Closed lwahonen closed 2 years ago

lwahonen commented 2 years ago

Hi everyone,

I've created a repro of this issue to https://github.com/lwahonen/jna-example

Running the code on AdoptOpenJDK 8u302 or Corretto 8u292 works perfectly, running it on Corretto 8u302 yields error -66748. Stack overflow tells me it's a change in some plist file? https://stackoverflow.com/questions/20145360/error-from-registration-server-when-publishing-audio-unit

Obviously this being an issue with AudioUnit and plist files, the issue only affects Mac users.

earthling-amzn commented 2 years ago

Thank you for bringing this to our attention. We're working on this now.

lwahonen commented 2 years ago

My guess: The xcode used to compile the JDK was updated, and now more stringently restricts access to deprecated APIs.

The reproducer can be patched by replacing all instances of FindNextComponent with AudioComponentFindNext, and OpenAComponent with AudioComponentInstanceNew. After this it works with both 8u292 and 8u302, with no change in functionality.

benty-amzn commented 2 years ago

Indeed, if you run the reproducer code with Corretto 8u302 and check the macos system logs (e.g. through Console.app) you will see

fault   12:10:38.168900-0700    java    This application, or a library it uses, is using the deprecated Component Manager for hosting Audio Components. This is not supported when rebuilding against the 11.00 or later SDK. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.

If you run the code with 8u292, you will see an additional line after this fault:

fault   12:11:52.557136-0700    java    This application, or a library it uses, is using the deprecated Component Manager for hosting Audio Components. This is not supported when rebuilding against the 11.00 or later SDK. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.
default 12:11:52.557702-0700    java                    AUHAL.cpp:1677  SetStreamUsage: Output stream enables: Stream 0 is ENABLED

Between these releases, Corretto 8's build system was updated to use the macos 11 sdk

otool -l /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home/bin/java | grep -A3 "LC_VERSION_MIN_MACOSX":

      cmd LC_VERSION_MIN_MACOSX
  cmdsize 16
  version 10.9
      sdk 11.3

Although the same API compatibility level is specified, the behavior of the SDK has changed and the deprecated AudioUnit v2 API is no longer available.

I believe strictly speaking Apple hasn't broken compatibility here, because the APIs in question are listed as available from macos 10.0-10.8 and so removing them when specifying a minimum macos version of 10.9 is "safe". macos 10.8 has been end-of-life since ~ 2015. For more information see Apple's audio unit v3 migration guide.