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

Ajit Ghaisas aghaisas at openjdk.java.net
Fri Jan 8 19:21:17 UTC 2021


On Fri, 8 Jan 2021 19:10:08 GMT, Ajit Ghaisas <aghaisas 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.
>
>> 
>> Maybe we can make this check version specific (maybe 10.12 for now) so
>> that in future version when opengl is removed, then this check will be
>> noop and if Metal fails, then it will quit.
>> 
>> Regards
>> Prasanta
> 
> It is better to avoid version specific check when we can cover all the combinations discussed in other comments. My last commit addresses it.

In the absence of specification, I have implemented the below combinations -

Current hard-coded Default pipeline is : OpenGL
If user specifies : Nothing --> Selected pipeline is : Default
If user specifies : opengl=true --> Selected pipeline is : OpenGL
If user specifies : opengl=false --> Selected pipeline is : Metal
If user specifies : metal=true --> Selected pipeline is : Metal
If user specifies : metal=false --> Selected pipeline is : OpenGL
If user specifies : opengl=true AND metal=false --> Selected pipeline is : OpenGL
If user specifies : opengl=false AND metal=true --> Selected pipeline is : Metal
If user specifies : opengl=true AND metal=true  --> Selected pipeline is : Default
If user specifies : opengl=false AND metal=false  --> Selected pipeline is : Default

Note that - I have not considered the order of VM options. If needed, that should be handled separately later.

If selected pipeline could not be initialized, then the other pipeline is used as fallback.
For fallback, appropriate message is logged only in verbose mode.
If fallback also fails (unlikely) - then a RuntimeException with appropriate message is thrown.

-------------

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


More information about the lanai-dev mailing list