From e4545a3a170797314445729b89952768e0569281 Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Tue, 23 Jul 2024 14:41:29 -0600 Subject: [PATCH] factored out SimOptions, set webgl:false for mobile safari, https://github.com/phetsims/gas-properties/issues/289 --- js/common/GasPropertiesConstants.ts | 16 +++++++++++++++- js/gas-properties-main.ts | 12 +++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/js/common/GasPropertiesConstants.ts b/js/common/GasPropertiesConstants.ts index 626fdc31..7962ca94 100644 --- a/js/common/GasPropertiesConstants.ts +++ b/js/common/GasPropertiesConstants.ts @@ -17,6 +17,8 @@ import { PanelOptions } from '../../../sun/js/Panel.js'; import gasProperties from '../gasProperties.js'; import GasPropertiesColors from './GasPropertiesColors.js'; import { ScreenOptions } from '../../../joist/js/Screen.js'; +import { SimOptions } from '../../../joist/js/Sim.js'; +import platform from '../../../phet-core/js/platform.js'; // for all panel-like containers const PANEL_CORNER_RADIUS = 5; @@ -32,6 +34,18 @@ const CREDITS: CreditsData = { qualityAssurance: 'Jaspe Arias, Jaron Droder, Clifford Hardin, Matthew Moore, Liam Mulhall, Jacob Romero, Nancy Salpepi, Luisa Vargas, Kathryn Woessner' }; +const SIM_OPTIONS: SimOptions = { + phetioDesigned: true, + credits: CREDITS, + + // WebGL is typically enabled for high-performance scenery.Sprites, which are used heavily by this sim. + // On iPadOS, the sim consistently crashed when WebGL was enabled, and we were unable to determine why. + // Disabling WebGL uses Canvas as the fallback for Sprites. The problem was not present on iOS, but we + // have no way to differentiate between Safari on iPadOS vs iOS, so WebGL is disabled on both platforms. + // See https://github.com/phetsims/gas-properties/issues/289. + webgl: !platform.mobileSafari +}; + const ACCORDION_BOX_OPTIONS: AccordionBoxOptions = { cornerRadius: PANEL_CORNER_RADIUS, contentXMargin: PANEL_X_MARGIN, @@ -94,7 +108,7 @@ const SCREEN_OPTIONS: Partial = { const GasPropertiesConstants = { - CREDITS: CREDITS, + SIM_OPTIONS: SIM_OPTIONS, // margins for all ScreenView instances SCREEN_VIEW_X_MARGIN: 20, diff --git a/js/gas-properties-main.ts b/js/gas-properties-main.ts index 8381a68a..e0c1211c 100644 --- a/js/gas-properties-main.ts +++ b/js/gas-properties-main.ts @@ -7,7 +7,7 @@ */ import PreferencesModel from '../../joist/js/preferences/PreferencesModel.js'; -import Sim from '../../joist/js/Sim.js'; +import Sim, { SimOptions } from '../../joist/js/Sim.js'; import simLauncher from '../../joist/js/simLauncher.js'; import { Utils } from '../../scenery/js/imports.js'; import Tandem from '../../tandem/js/Tandem.js'; @@ -18,9 +18,12 @@ import EnergyScreen from './energy/EnergyScreen.js'; import ExploreScreen from './explore/ExploreScreen.js'; import GasPropertiesStrings from './GasPropertiesStrings.js'; import IdealScreen from './ideal/IdealScreen.js'; +import { combineOptions } from '../../phet-core/js/optionize.js'; simLauncher.launch( () => { + const titleStringProperty = GasPropertiesStrings[ 'gas-properties' ].titleStringProperty; + const screens = [ new IdealScreen( Tandem.ROOT.createTandem( 'idealScreen' ) ), new ExploreScreen( Tandem.ROOT.createTandem( 'exploreScreen' ) ), @@ -28,10 +31,7 @@ simLauncher.launch( () => { new DiffusionScreen( Tandem.ROOT.createTandem( 'diffusionScreen' ) ) ]; - const sim = new Sim( GasPropertiesStrings[ 'gas-properties' ].titleStringProperty, screens, { - phetioDesigned: true, - webgl: true, // Enabled for high-performance Sprites - credits: GasPropertiesConstants.CREDITS, + const options = combineOptions( {}, GasPropertiesConstants.SIM_OPTIONS, { preferencesModel: new PreferencesModel( { visualOptions: { supportsProjectorMode: true @@ -44,6 +44,8 @@ simLauncher.launch( () => { } ) } ); + const sim = new Sim( titleStringProperty, screens, options ); + // Log whether we're using WebGL, which is the preferred rendering option for Sprites phet.log && phet.log( `using WebGL = ${phet.chipper.queryParameters.webgl && Utils.isWebGLSupported}` );