Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting Material Y freezes the sim [Safari] #192

Closed
Nancy-Salpepi opened this issue Jun 12, 2024 · 5 comments
Closed

Selecting Material Y freezes the sim [Safari] #192

Nancy-Salpepi opened this issue Jun 12, 2024 · 5 comments
Assignees
Labels

Comments

@Nancy-Salpepi
Copy link

Nancy-Salpepi commented Jun 12, 2024

Test device
MacBook Air M1 chip

Operating System
14.5

Browser
Safari 17.5

Problem description
For phetsims/qa#1095, seen with Safari but not Chrome:
Choosing Material Y on the Explore Screen freezes the sim. If I reload the sim, nothing is clickable. I have to open a new tab or window.
This doesn't happen with the other mystery materials.
Nothing appeared in the console.

Steps to reproduce

  1. Using Safari, go to the Explore Screen
  2. Select Material Y from the combobox

Visuals

mysteryObjectY.mp4
Troubleshooting information: !!!!! DO NOT EDIT !!!!! Name: ‪Buoyancy‬ URL: https://phet-dev.colorado.edu/html/buoyancy/1.0.0-dev.9/phet/buoyancy_all_phet.html Version: 1.0.0-dev.9 2024-06-12 15:13:18 UTC Features missing: applicationcache, applicationcache, touch Flags: pixelRatioScaling User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15 Language: en-US Window: 1380x706 Pixel Ratio: 2/1 WebGL: WebGL 1.0 GLSL: WebGL GLSL ES 1.0 (1.0) Vendor: WebKit (WebKit WebGL) Vertex: attribs: 16 varying: 30 uniform: 1024 Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 32) Max viewport: 16384x16384 OES_texture_float: true Dependencies JSON: {}
@Nancy-Salpepi Nancy-Salpepi added the type:bug Something isn't working label Jun 12, 2024
@samreid
Copy link
Member

samreid commented Jun 12, 2024

This patch identifies the area of the problem, I'll continue investigating:

Subject: [PATCH] Whitespace, see https://github.com/phetsims/density-buoyancy-common/issues/189
---
Index: js/buoyancy/view/BuoyancyExploreScreenView.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/buoyancy/view/BuoyancyExploreScreenView.ts b/js/buoyancy/view/BuoyancyExploreScreenView.ts
--- a/js/buoyancy/view/BuoyancyExploreScreenView.ts	(revision 35e9d20881fc236083bee6a6cc7682e3952a0032)
+++ b/js/buoyancy/view/BuoyancyExploreScreenView.ts	(date 1718222999087)
@@ -114,7 +114,7 @@
           mass.volumeProperty.value = 0.003;
         }
         else if ( material === Material.MATERIAL_Y ) {
-          mass.volumeProperty.value = 0.001;
+          mass.volumeProperty.value = 0.003;
         }
       } );
     } );

@samreid
Copy link
Member

samreid commented Jun 12, 2024

@zepumph and I saw that the change to Property to make it queue-based caused the locks to fail. We experimented that changing to stack-based solved the problem, but we also saw that rounding to TOLERANCE was another way to short circuit the cycles because they seemed caused by rounding errors. I'll commit momentarily.

@samreid
Copy link
Member

samreid commented Jun 12, 2024

Migration tests are working well, fuzz tests are working well, safari is no longer crashing under material Y. I sneaked in deleting some unused intersection code. Closing.

@samreid samreid closed this as completed Jun 12, 2024
@samreid samreid reopened this Jun 12, 2024
@samreid
Copy link
Member

samreid commented Jun 12, 2024

@zepumph said the internal material property had locks, and recommended using the 'stack' strategy in those cases. Let's assign @zepumph to review the above and take that next step.

@samreid samreid assigned zepumph and unassigned samreid Jun 12, 2024
zepumph added a commit that referenced this issue Jun 13, 2024
Signed-off-by: Michael Kauzmann <michael.kauzmann@colorado.edu>
@zepumph
Copy link
Member

zepumph commented Jun 13, 2024

Yes thanks. This code here is buggy without ensuring that we eagerly call the listeners during the lock.

let materialChangeLocked = false;
Multilink.lazyMultilink( [ model.customDensityProperty, model.bottle.interiorMassProperty, model.customDensityControlVisibleProperty ], density => {
if ( !materialChangeLocked && model.bottle.interiorMaterialProperty.value.custom ) {
materialChangeLocked = true;
model.bottle.interiorMaterialProperty.value = Material.createCustomSolidMaterial( {
density: density * DensityBuoyancyCommonConstants.LITERS_IN_CUBIC_METER,
densityRange: model.customDensityProperty.range.copy().times( DensityBuoyancyCommonConstants.LITERS_IN_CUBIC_METER )
} );
materialChangeLocked = false;
}
} );

@zepumph zepumph closed this as completed Jun 13, 2024
samreid added a commit that referenced this issue Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants