JDK-8132775 : [macosx] JavaFX forces the use of discrete GPU
Type:Bug
Component:javafx
Sub-Component:graphics
Affected Version:8
Priority:P2
Status:Resolved
Resolution:Fixed
OS:os_x
Submitted:2015-07-31
Updated:2020-01-31
Resolved:2015-08-24
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.
24-08-2015
One comment:
+ 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:
if (!pFormat)
{
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
22-08-2015
Kevin and Sergey,
Please review the proposed fix. I have successfully tested this fix works on self-contained application with modified Info.plist.
http://cr.openjdk.java.net/~ckyang/JDK-8132775/webrev.00/
21-08-2015
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.
17-08-2015
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
--- 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;
+
// Zero-terminate
attribs[index++] = 0;