Skip to content
This repository has been archived by the owner. It is now read-only.

8258754: Gracefully fallback to the OpenGL rendering pipeline if Metal rendering pipeline initialization fails #147

Closed
wants to merge 10 commits into from
@@ -92,8 +92,16 @@ private static void initJavaFlags() {
PropertyState oglState = getBooleanProp("sun.java2d.opengl", PropertyState.UNSPECIFIED);
PropertyState metalState = getBooleanProp("sun.java2d.metal", PropertyState.UNSPECIFIED);

Copy link
Collaborator

@prrace prrace Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right here we could add
if (metalState == PropertyState.UNSPECIFIED && oglState == PropertyState.UNSPECIFIED) {
// change this line to set metalState to toggle the default pipeline.
oglState = PropertyState.ENABLED;
}
This makes it easier to set the default

Copy link
Collaborator Author

@aghaisas aghaisas Jan 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion.
We need to handle other invalid combinations here as well - I will update the code.

// Note : Currently OpenGL is the default pipeline.
// Switch logic in this if-else ladder if default pipeline is changed to Metal
// Handle invalid combinations to use the default rendering pipeline
// Current default rendering pipeline is OpenGL
// (The default can be changed to Metal in future just by toggling two states in this if condition block)
if ((oglState == PropertyState.UNSPECIFIED && metalState == PropertyState.UNSPECIFIED) ||
(oglState == PropertyState.DISABLED && metalState == PropertyState.DISABLED) ||
(oglState == PropertyState.ENABLED && metalState == PropertyState.ENABLED)) {
oglState = PropertyState.ENABLED; // Enable default pipeline
metalState = PropertyState.DISABLED; // Disable non-default pipeline
}

if (metalState == PropertyState.UNSPECIFIED) {
if (oglState == PropertyState.DISABLED) {
oglEnabled = false;