I develop software for macOS, and my programs are emitted this warning:
2023-10-05 21:23:20.553 java[87648:12138370] apply_selection_policy_once: avoid use of removable GPUs (via net.java.openjdk.java:GPUSelectionPolicy->avoidRemovable)
This warning gets emitted when I do the following:
- Start IntelliJ from Jetbrains Toolbox
- Run a Gradle
runtask to run a java application from IntelliJ that has a user interface.
Even a barebones app will emit the warning. For example, this kotlin app will emit the warning:
import javax.swing.JFrame
fun main() {
JFrame("FrameDemo")
}
Note the call to JFrame is required. This warning is only emitted if metal APIs are called.
Note also that the warning is only emitted if the app is run from Intellij. If I run the app from the terminal, the warning is not emitted.
The reason that the warning is only emitted when running from IntelliJ is that IntellIj is a subprocess of JetBrains Toolbox, and the Info.plist of Jetbrains Toolbox contains the following:
<true/>
<key>GPUEjectPolicy</key>
<string>relaunch</string>
<key>GPUSelectionPolicy</key>
<string>avoidRemovable</string>
I have confirmed that the plist keys above are a requirement to reproduce the issue. I deleted the keys from the plist and restarted JetBrains Toolbox, and the warning was no longer emitted.
The above, however, is not a viable workaround. Modifying the plist caused the codesign checks of JetBrains Toolbox to fail. As a result, MacOS disallows accessibility permissions for JetBrains Toolbox and all of its descendents, which I require.
The warning is produced from metal. The only reason I know this is because when I google it, this metal documentation page for GPUSelectionPolicy comes up.
I have never in my life used or heard of an eGPU before this. I use a MacbookPro. I disconnected every single thing physically attached to my Macbook (monitors and external storage), and this warning still showed. Given what we know, I think it is time to suspect that it is a bug within the Metal API or deeper.
However, despite clearly being a metal API issue, Apple Developer Support refused my ticket. They said this was a third party issue since "the issue doesn't occur in the terminal". I strongly believe the support agent who responded to my request was mistaken, and that this is an Apple issue and not a 3rd party issue. It is nonsensical that I would get an eGPU-related warning on a machine that has never connected to a an eGPU once in its lifetime.
I am not the only person who has seen this issue. While sightings are sparse, they exist. Searching, I have found the following examples of people who have also spotted this:
https://stackoverflow.com/questions/74473258/xcodebuild-fail-flutter https://github.com/BlueM/Pashua/issues/14
In the first issue, the reported said they had a "new MacBook pro m1 max". This is the same specs of my macbook, so likely we have the same exact model. While they didn't specify, I gather they also are not using an eGPU.
In the second issue, the person also did not specify whether or not the use an eGPU.
This is my existing issue on YouTrack (JetBrains issue tracker)
https://youtrack.jetbrains.com/issue/IDEA-331445/Unactionable-and-false-GPUSelectionPolicy-warning-while-executing-java-desktop-application-from-IntelliJ