mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2026-01-08 01:21:42 +01:00
JBR-4666 java.lang.InternalError: Error - unable to initialize Metal after recreation of graphics device.
Reverted fix of the JRE-359 (CGraphicsEnvironment.getDefaultScreenDevice() returns null) Logged exception after first attempt to create graphics device
This commit is contained in:
@@ -88,7 +88,7 @@ public final class CGraphicsDevice extends GraphicsDevice
|
||||
if (MTLGraphicsConfig.isMetalUsed()) {
|
||||
// Should not fall back to OpenGL if Metal has been used before
|
||||
// (it could cause CCE during replace of surface data)
|
||||
throw new InternalError("Error - unable to initialize Metal" +
|
||||
throw new IllegalStateException("Error - unable to initialize Metal" +
|
||||
" after recreation of graphics device." + errorMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import java.util.Map;
|
||||
import sun.java2d.MacosxSurfaceManagerFactory;
|
||||
import sun.java2d.SunGraphicsEnvironment;
|
||||
import sun.java2d.SurfaceManagerFactory;
|
||||
import sun.lwawt.macosx.CThreading;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
/**
|
||||
* This is an implementation of a GraphicsEnvironment object for the default
|
||||
@@ -52,6 +52,9 @@ import sun.lwawt.macosx.CThreading;
|
||||
*/
|
||||
public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
|
||||
private static final PlatformLogger logger =
|
||||
PlatformLogger.getLogger(CGraphicsEnvironment.class.getName());
|
||||
|
||||
/**
|
||||
* Fetch an array of all valid CoreGraphics display identifiers.
|
||||
*/
|
||||
@@ -160,35 +163,24 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
|
||||
private synchronized void initDevices() {
|
||||
Map<Integer, CGraphicsDevice> old = new HashMap<>(devices);
|
||||
devices.clear();
|
||||
try {
|
||||
mainDisplayID = CThreading.privilegedExecuteOnAppKit(
|
||||
CGraphicsEnvironment::getMainDisplayID);
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not get main display ID: " +
|
||||
e.getMessage() );
|
||||
}
|
||||
mainDisplayID = getMainDisplayID();
|
||||
|
||||
// initialization of the graphics device may change list of displays on
|
||||
// hybrid systems via an activation of discrete video.
|
||||
// So, we initialize the main display first, then retrieve actual list
|
||||
// of displays, and then recheck the main display again.
|
||||
if (!old.containsKey(mainDisplayID)) {
|
||||
old.put(mainDisplayID, new CGraphicsDevice(mainDisplayID));
|
||||
}
|
||||
|
||||
int[] displayIDs;
|
||||
try {
|
||||
displayIDs = CThreading.privilegedExecuteOnAppKit(
|
||||
CGraphicsEnvironment::getDisplayIDs);
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not get display IDs: " +
|
||||
e.getMessage());
|
||||
try {
|
||||
old.put(mainDisplayID, new CGraphicsDevice(mainDisplayID));
|
||||
} catch (IllegalStateException e) {
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
logger.fine("Unable to initialize graphics device for displayID=" +
|
||||
mainDisplayID + " : " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int[] displayIDs = getDisplayIDs();
|
||||
if (displayIDs.length == 0) {
|
||||
// we could throw AWTError in this case.
|
||||
displayIDs = new int[]{mainDisplayID};
|
||||
|
||||
Reference in New Issue
Block a user