JDK-8132775 : [macosx] JavaFX forces the use of discrete GPU
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
Thanks for the good catch. I will fix it with an adjust message before commit.
+ if (!pFormat)
+ LOG("GlassView3D initWithFrame: initWithAttributes failed! No OpenGL pixel format");
I doubt this can happen in practice, but since you are checking for a failure, the safest thing to is to also assign the default pixel format in this case:
pFormat = [NSOpenGLView defaultPixelFormat];
LOG("GlassView3D initWithFrame: initWithAttributes failed! No OpenGL pixel format");
You probably also want to adjust the message as a result. Other than that, this fix looks good to go into JDK 9. We can then consider a backport to JDK 8u-dev, although given that the application needs to manually edit the Info.plist file to enable this, I don't know whether this is important enough to backport (as opposed to the Java2D fix which does need to be backported). It is worth considering, but we will need to test it for any regressions.
+1 with the addition of setting the default value in the failure case
Kevin and Sergey,
Please review the proposed fix. I have successfully tested this fix works on self-contained application with modified Info.plist.
Just an additional information. I have evaluated that JavaFX rendered fine using Intel GPU on a dual GPU Mac system. I used gfxCardStatus (v2.3) to force my dual GPU MacBook Pro to integrated only mode in the testing.
The fix in JavaFX should be very simple based on my reading of JDK-8041900 and the discussion on the Apple technical mailing list. However this GPU switching doesn't seem to take effect for Java in most cases.
Here is the proposed fix for JavaFX once JDK-8041900 (JDK including Info.plist) is fixed:
diff --git a/modules/graphics/src/main/native-prism-es2/macosx/MacOSXWindowSystemInterface.m b/modules/graphics/src/main/native-prism-es2/macosx/MacOSXWindowSystemInterface.m
@@ -58,6 +58,9 @@
attribs[index++] = NSOpenGLPFADepthSize;
attribs[index++] = ivalues[com_sun_prism_es2_GLPixelFormat_Attributes_DEPTH_SIZE];
+ // Don't force using the dedicated GPU
+ attribs[index++] = NSOpenGLPFAAllowOfflineRenderers;
attribs[index++] = 0;