JDK-8296654 : [macos] Crash when launching JavaFX app with JDK that targets SDK 13
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: jfx20,jfx17
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: aarch64
  • Submitted: 2022-11-07
  • Updated: 2024-08-30
  • Resolved: 2022-12-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 Other
8u381Fixed jfx11.0.19Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
macOS 13.0 / Apple M1
Java 17.0.6+1


A DESCRIPTION OF THE PROBLEM :
JavaFX app (simple Hello) crashes on startup when built with JDK17u on Xcode 14.1 (sdk13.0).
Xcode 14.1 is required for Mac ports and homebrew binary builds for macOS Ventura.

Tried the following combinations.

* JavaFX(sdk13.0, minos11.0) + JDK 17.0.5+8(sdk12.3, minos11.0) -- no problem
* JavaFX(sdk13.0, minos11.0) + JDK 17.0.6+1(sdk13.0, minos11.0) -- process crash

Confirmed on aarch64 only, not sure if this can be reproduced on x86_64.

I have identified the cause of this problem and will provide a fix code (see Workaround section). I have signed the OCA.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
* Build JDK17u with Xcode 14.1.
* Launch the test app.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Test app launches normally.
ACTUAL -
Test apps do not launch and process crashes.

---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class HelloTest extends Application{

	@Override
	public void start(Stage primaryStage) throws Exception {
		BorderPane root = new BorderPane();
		
		primaryStage.setScene(new Scene(root, 400, 400));
		primaryStage.show();
	}

	public static void main(String arg[]) {
		Application.launch(arg);
	}
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
diff --git a/modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m b/modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m
index 41fc4c7c4f..48bfa1b648 100644
--- a/modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m
+++ b/modules/javafx.graphics/src/main/native-glass/mac/GlassViewDelegate.m
@@ -262,8 +262,9 @@ - (void)setFrameSize:(NSSize)newSize
     GET_MAIN_JENV;
     (*env)->CallVoidMethod(env, self->jView, jViewNotifyResize, (int)newSize.width, (int)newSize.height);
     GLASS_CHECK_EXCEPTION(env);
-
-    [self->nsView removeTrackingRect:self->trackingRect];
+    if (self->trackingRect) {
+      [self->nsView removeTrackingRect:self->trackingRect];
+    }
     self->trackingRect = [self->nsView addTrackingRect:[self->nsView bounds] owner:self->nsView userData:nil assumeInside:NO];
 }
 
@@ -276,14 +277,18 @@ - (void)setFrame:(NSRect)frameRect
     GET_MAIN_JENV;
     (*env)->CallVoidMethod(env, self->jView, jViewNotifyResize, (int)frameRect.size.width, (int)frameRect.size.height);
     GLASS_CHECK_EXCEPTION(env);
+    if (self->trackingRect) {
+      [self->nsView removeTrackingRect:self->trackingRect];
+    }
 
-    [self->nsView removeTrackingRect:self->trackingRect];
     self->trackingRect = [self->nsView addTrackingRect:[self->nsView bounds] owner:self->nsView userData:nil assumeInside:NO];
 }
 
 - (void)updateTrackingAreas
 {
-    [self->nsView removeTrackingRect:self->trackingRect];
+    if (self->trackingRect) {
+      [self->nsView removeTrackingRect:self->trackingRect];
+    }
     self->trackingRect = [self->nsView addTrackingRect:[self->nsView bounds] owner:self->nsView userData:nil assumeInside:NO];
 }

FREQUENCY : always



Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jfx11u/pull/128 Date: 2023-02-03 15:34:09 +0000
03-02-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jfx17u/pull/109 Date: 2023-02-03 15:31:58 +0000
03-02-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/1003 Date: 2023-01-19 13:05:49 +0000
19-01-2023

Changeset: 5b96d348 Author: Kevin Rushforth <kcr@openjdk.org> Date: 2022-12-22 15:22:56 +0000 URL: https://git.openjdk.org/jfx/commit/5b96d348ebcabb4b6d2e1d95937de3c82a1f6876
22-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jfx/pull/981 Date: 2022-12-22 00:13:03 +0000
22-12-2022

I can reproduce this. Regardless of the version of Xcode / MacOSX SDK that JavaFX is built on, all JavaFX applications will start crashing when run on a JDK that is built with Xcode 14.1 + MacOSX SDK 13. That makes this a more serious bug, since existing versions of the JavaFX SDK will simply stop working (all applications will crash on startup) if you run it on a JDK built with the latest Xcode.
21-12-2022

I see that there is a patch provided in the Description. Perhaps the bug reporter would like to contribute it as a pull request?
09-11-2022

I don't think this is a duplicate of JDK-8295779, since that bug is a build failure in the JDK, whereas this bug is about running JavaFX once you are able to build using Xcode 14.1.
09-11-2022

Duplicate of JDK-8295779
09-11-2022