From da0b93217520b52c82672905b4613d661d35ea98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?moon=20dav=C3=A9?= Date: Mon, 19 Oct 2026 17:54:38 -0400 Subject: [PATCH] Handle the edge case of Preprocessor passing back a string that says WEBGPU --- java/src/processing/mode/java/runner/Runner.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/java/src/processing/mode/java/runner/Runner.java b/java/src/processing/mode/java/runner/Runner.java index 3813928ea..f241fe95c 100644 --- a/java/src/processing/mode/java/runner/Runner.java +++ b/java/src/processing/mode/java/runner/Runner.java @@ -294,6 +294,18 @@ public boolean launchVirtualMachine(boolean present, String[] args) { } + // the results of `build.sketchRunner()` returns a string without being checked so this is actually a code-smell. + // This function should not exist. + // In a better world as I understand it now, we should be making some fixes in the PreProcessor + // There are two things to consider at this moment: + // When we use the constant P2D or P3D there is actually no check for converting this into the PConstant.* value. + // So it doesn't actually do anything. WEBGPU actually does do something which led to this function. + // TODO: Lets try to remove this function, or create something that considers P2D and P3D + // This will lead to cleaning up the PreProcessor and help us learn its architecture so we can move towards a healthy refactor. + static private boolean isWebGPU(String renderer) { + return "WEBGPU".equals(renderer) || PConstants.WEBGPU.equals(renderer); + } + protected StringList getMachineParams() { StringList params = new StringList(); @@ -343,7 +355,7 @@ protected StringList getMachineParams() { //params.append("-Dcom.apple.mrj.application.apple.menu.about.name=" + // build.getSketchClassName()); - if (PConstants.WEBGPU.equals(build.getSketchRenderer())) { + if (isWebGPU(build.getSketchRenderer())) { params.append("-XstartOnFirstThread"); } } @@ -518,7 +530,7 @@ protected StringList getSketchParams(boolean present, String[] args) { // Only disable AWT for the WebGPU renderer, which uses GLFW and // cannot coexist with AWT. All other renderers still depend on AWT // for display detection, displayWidth/displayHeight, pixelDensity(), etc. - if (PConstants.WEBGPU.equals(build.getSketchRenderer())) { + if (isWebGPU(build.getSketchRenderer())) { params.append(PApplet.ARGS_DISABLE_AWT); }