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

Kevin Rushforth kcr at openjdk.java.net
Fri Jan 8 13:28:07 UTC 2021

On Fri, 8 Jan 2021 08:00:42 GMT, Jayathirth D V <jdv at openjdk.org> wrote:

> 1. No options - Use OpenGL(Switch to Metal later when we want to make it default)
> 2. opengl == true || metal == false - Use OpenGL
> 3. metal initialization fails print log in verbose- Use OpenGL
> 4. metal == true || opengl == false - Use Metal
> 5. opengl initialization fails print log in verbose(In initial release when OpenGL is default, i am not 100% sure whether we should try Metal pipeline or just exit) - Use Metal / exit
> 6. Both fails print log and exit

Unless I am misreading what you wrote, I think you have 3 and 5 switched. I would write it a bit differently in any case.

* No options - use the default pipeline (OpenGL today, Metal later), fallback to the other pipeline (Metal today, OpenGL later) if the default pipeline init fails

This is the most important case, since it is what end users will typically see (i.e., setting sun.java2d.metal is a developer option that wouldn't typically be set in production). In the absence of any flags we must fallback to the non-default pipeline if initializing the default pipeline fails.

* opengl == true - Use OpenGL, fallback to metal if OpenGL init fails

* metal == true - Use Metal, fallback to OpenGL if Metal init fails

* In all cases above, if both pipelines fail to initialize, then log error and throw an exception (a library should never call exit).

Btw, if both are set (once an "OpenGL" flag is added for the Mac), the precedence would be decided by whichever you check first -- probably metal, but it really doesn't matter as long as it is clearly spelled out.


PR: https://git.openjdk.java.net/lanai/pull/147

More information about the lanai-dev mailing list