JDK-8303880 : Ensemble crashes when run on M1
  • Type: Bug
  • Component: javafx
  • Sub-Component: graphics
  • Affected Version: internal
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: os_x
  • CPU: generic
  • Submitted: 2023-03-09
  • Updated: 2024-07-06
  • Resolved: 2023-03-14
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.
Other
internalFixed
Related Reports
Blocks :  
Description
If we launch Ensemble8 on latest metal branch code. It crashes at MetalShader.setFloat2() with following log :

>>> MTLShader.setConstant() : fragmentFunctionName : FillRoundRect_Color
    MTLShader.setConstant() name = oinvarcradii, f0 = 0.083333336, f1 = 0.083333336
2023-03-09 14:23:05.380 java[8931:260143] 
2023-03-09 14:23:05.380 java[8931:260143] -> JNICALL Native: MTLShader_nSetFloat2
2023-03-09 14:23:05.380 java[8931:260143] 
2023-03-09 14:23:05.380 java[8931:260143] >>>> MetalShader.setFloat2() : argumentName = oinvarcradii, f0= 0.083333, f1= 0.083333
2023-03-09 14:23:05.380 java[8931:260143]      MetalShader.setFloat2()----> fragFuncName: FillRoundRect_Color
2023-03-09 14:23:05.380 java[8931:260143]     Value: 0 for key: oinvarcradii
2023-03-09 14:23:05.380 java[8931:260143]     index.intValue: 0

And this crash is seen only when we use setFloat2() with other set of arguments it is working fine.
Comments
Changeset: 8ed68fc8 Author: Ambarish Rapte <arapte@openjdk.org> Date: 2023-03-14 16:12:56 +0000 URL: https://git.openjdk.org/jfx-sandbox/commit/8ed68fc838b05fe020c891335a30a1d47b931f3c
14-03-2023

---- newArgumentEncoder:84: failed assertion `Buffer argument uniforms (buffer index: 0) of function FillRoundRect_Color is not an indirect argument buffer. If uniforms is expected to be an argument buffer, this could be a shader bug. Argument buffers can be distinguished from regular buffers if they contain buffers, textures, samplers, or any element with the [[id]] attribute' ---- We see this Assertion on Ventura, and also on Monterey but only with MTL_SHADER_VALIDATION=1. Based on the above assertion message and MTLArgumentEncoder documentation: A prime requirement to use MTLArgumentEncoder is that the struct of uniform variables that we use to create MTLArgumentEncoder must contain at least one variable of these types : buffers, textures, samplers, or any element with the [[id]] attribute’. But we have some(22) prism shaders for which these structs are either empty or have just vector_float2's for example : typedef struct FillRoundRect_Color_Uniforms { vector_float2 oinvarcradii; } FillRoundRect_Color_Uniforms; So we need to make sure that such structs contain at least one variable of the required types. Fix: is to introduce an extra unused variable texture2d<float> UNUSED; in the uniform struct of those shaders which do not already have a texture2d. This solves the problem at cost of 4 extra bytes for each of those 22 prism shaders.
14-03-2023

With RoundedRect sample drawing i am also the same failure on M1. With METAL_DEVICE_WRAPPER_TYPE enabled i see same log : >>> MTLShader(): fragFuncName = FillRoundRect_Color MTLResourceFactory: Prism - createStockShader: FillRoundRect_Color 2023-03-13 13:57:55.271 java[48920:1507867] 2023-03-13 13:57:55.271 java[48920:1507867] >>>> JNICALL Native: MTLShader_nCreateMetalShader 2023-03-13 13:57:55.272 java[48920:1507867] 2023-03-13 13:57:55.272 java[48920:1507867] >>>> MetalShader.initWithContext()----> fragFuncName: FillRoundRect_Color 2023-03-13 13:57:55.272 java[48920:1507867] getPRISMDict 2023-03-13 13:57:55.272 java[48920:1507867] getPRISMDict() : calling -> getFillRoundRect_Color_Uniform_VarID_Dict() 2023-03-13 13:57:55.272 java[48920:1507867] -> Native: MetalShader.initWithContext() Value: 0 for key: oinvarcradii newArgumentEncoder:84: failed assertion `Buffer argument uniforms (buffer index: 0) of function FillRoundRect_Color is not an indirect argument buffer. If uniforms is expected to be an argument buffer, this could be a shader bug. Argument buffers can be distinguished from regular buffers if they contain buffers, textures, samplers, or any element with the [[id]] attribute' And i have macOS Ventura 13.2.1
13-03-2023

Enabling Metal API Validation (set environment variable METAL_DEVICE_WRAPPER_TYPE=1) gives below error- >>> MTLResourceFactory.createShader() shaderName: FillRoundRect_Color samplers: {} params: {oinvarcradii=0} maxTexCoordIndex: 1 isPixcoordUsed: false isPerVertexColorUsed: true >>> MTLShader.createShader()1 fragFuncName= FillRoundRect_Color samplers= {} params= {oinvarcradii=0} maxTexCoordIndex= 1 isPixcoordUsed= false isPerVertexColorUsed= true >>> MTLShader(): fragFuncName = FillRoundRect_Color 2023-03-10 16:04:07.680 java[8702:195580] 2023-03-10 16:04:07.680 java[8702:195580] >>>> JNICALL Native: MTLShader_nCreateMetalShader 2023-03-10 16:04:07.680 java[8702:195580] 2023-03-10 16:04:07.680 java[8702:195580] >>>> MetalShader.initWithContext()----> fragFuncName: FillRoundRect_Color 2023-03-10 16:04:07.680 java[8702:195580] getPRISMDict 2023-03-10 16:04:07.680 java[8702:195580] getPRISMDict() : calling -> getFillRoundRect_Color_Uniform_VarID_Dict() 2023-03-10 16:04:07.680 java[8702:195580] -> Native: MetalShader.initWithContext() Value: 0 for key: oinvarcradii newArgumentEncoder:84: failed assertion `Buffer argument uniforms (buffer index: 0) of function FillRoundRect_Color is not an indirect argument buffer. If uniforms is expected to be an argument buffer, this could be a shader bug. Argument buffers can be distinguished from regular buffers if they contain buffers, textures, samplers, or any element with the [[id]] attribute' Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
10-03-2023

Drawing a rounded rectangle causes this crash. Minimal example to reproduce this crash on my system- ---------------------------------------------------------------------- //Drawing a Rectangle Rectangle rect = new Rectangle(); rect.setWidth(200.0f); rect.setHeight(150.0f); rect.setArcWidth(50.0); rect.setArcHeight(50.0); Group gr = new Group(rect); Scene scene = new Scene(gr, 300, 300); primaryStage.setScene(scene); primaryStage.show(); -------------------------------------------------------------------------------------- Commenting out setArcWidth and setArcHeight - results in no crash - with simple rectangle being drawn. Drawing a rounded rectangle uses a different shader - FillRoundRect_Color.metal. Looks like there is some issue in the way we send data to this shader.
10-03-2023

Observed this on my macBook x64 with discrete graphics card active. Attached the hs_err file.
09-03-2023