itwinjs-core icon indicating copy to clipboard operation
itwinjs-core copied to clipboard

Set antialiasSamples=4 crashes on Mac

Open a-gagnon opened this issue 2 years ago • 16 comments

Describe the bug This is an issue that @ezmobivietnam is experiencing with our civil views using his Macbook Pro 2019. Whenever the antialiasSamples is set, the WebGL context is lost and nothing works anymore.

To Reproduce Please refer to the following sandbox: https://www.itwinjs.org/sandboxes/gagnon-a/webgl_context_macos_binh

Loading the sandbox should be sufficient to reproduce the issue. The crux of the problem is the following lines:

  const onViewportRef = (vp: ScreenViewport) => {
    vp.antialiasSamples = 4;
    console.log('Adjusted to 4 antialias samples');
  }

Expected behavior Changing a setting that is not supported by the user's browser/WebGL capabilities should not crash the app. Ideally, it should just ignore it.

Screenshots Screenshot 2023-09-21 at 3 17 21 PM Screenshot 2023-09-21 at 2 33 30 PM

Desktop (please complete the applicable information):

Macbook Pro 2019

  • Processor: 2.6 GHz 6-Core Intel Core i7
  • Graphics: AMD Radeon Pro 5300M 4 GB Intel UHD Graphics 630 1536 MB
  • Memory: 16 GB 2667 MHz DDR4
  • macOS: Ventura 13.5.2 (22G91)
  • Getting the same results with Chrome, Edge and Firefox
  • iTwin.js Version: 3.7.7 (sandbox), 4.x (deployed pineapple)

a-gagnon avatar Sep 26 '23 15:09 a-gagnon

Please send to the compatibility checker and report back with the number of antialias samples reported and all of the system information. image image

Then please find out how to configure the MacBook/browser to use the GPU. It is currently using software rendering, which is inappropriate for any 3D application.

pmconne avatar Sep 26 '23 15:09 pmconne

Hi @pmconne , here is the screenshot of the compatibility checker. Screenshot 2023-09-26 at 12 02 55 PM

ezmobivietnam avatar Sep 26 '23 15:09 ezmobivietnam

here is the screenshot of the compatibility checker.

Did you change your browser to use your GPU? Because @a-gagnon's screenshot shows software rendering and "major performance caveat", while your screenshot shows hardware rendering an no such caveat.

pmconne avatar Sep 26 '23 16:09 pmconne

here is the screenshot of the compatibility checker.

Did you change your browser to use your GPU? Because @a-gagnon's screenshot shows software rendering and "major performance caveat", while your screenshot shows hardware rendering an no such caveat.

I took the screen caps from an earlier conversion to create this bug report, perhaps some of it is out of context (?) @ezmobivietnam were you getting the same errors using the sandbox and the civil model from infrastructure cloud?

a-gagnon avatar Sep 26 '23 16:09 a-gagnon

here is the screenshot of the compatibility checker.

Did you change your browser to use your GPU? Because @a-gagnon's screenshot shows software rendering and "major performance caveat", while your screenshot shows hardware rendering an no such caveat.

No, I change nothing. I use the default browser settings. Regarding the performance caveat, it happens randomly. I just got it two times.

ezmobivietnam avatar Sep 26 '23 16:09 ezmobivietnam

here is the screenshot of the compatibility checker.

Did you change your browser to use your GPU? Because @a-gagnon's screenshot shows software rendering and "major performance caveat", while your screenshot shows hardware rendering an no such caveat.

I took the screen caps from an earlier conversion to create this bug report, perhaps some of it is out of context (?) @ezmobivietnam were you getting the same errors using the sandbox and the civil model from infrastructure cloud?

I got the same error. Below is the screenshots on infrastructure cloud Screenshot 2023-09-26 at 1 01 42 PM Screenshot 2023-09-26 at 1 01 53 PM

Note: I have tried with different browsers like Chome, Ms Edge and Firefox and got the same error.

ezmobivietnam avatar Sep 26 '23 17:09 ezmobivietnam

@markschlosseratbentley @iTwin/itwinjs-core-display

pmconne avatar Sep 26 '23 17:09 pmconne

@a-gagnon @ezmobivietnam

Are you saying that your browser randomly goes from using a GPU to not using a GPU every time you run the compatibility checker? If so, that sounds like a configuration problem.

markschlosseratbentley avatar Sep 26 '23 17:09 markschlosseratbentley

@markschlosseratbentley , Finally, I could reproduce the issue of showing the error and the performance warning. Below are the steps:

  1. Step 1. Open the imodel https://qa-infrastructurecloud.bentley.com/db4c11e6-25c8-4e08-8733-ddc1ca3b779d/manage-imodel/unified-viewer/c23aab84-8eb7-4038-acc5-1477ef89a8ca/a8a14b1db8dd913469d3291c7120d4f8742a3d0e
  2. Step 2. Open the Civil frontstage and draw 2-Point cross-section
  3. Step 3. Noticed an alert "Oops, something went wrong please reload the page" is displayed
  4. Step 4: Reload the imodel, repeat the two steps 2 - 3 several times until the loading time of the imodel is increased significantly then go to step 5.
  5. Step 5: After the iModel is loaded, check and notice that the Compatibility Warning was displayed.
  6. Step 6: Open the Civil frontstage and draw 2-Point cross-section again
  7. Step 7: Confirm that the 2-Point cross-section works successfully as designed this time.

I have a video recording demonstrating these steps. I will send it to you privately via Ms Team if it helps.

Thanks, Binh

ezmobivietnam avatar Sep 26 '23 20:09 ezmobivietnam

@a-gagnon the original description states that setting the viewport's antialiasSamples to 4 causes the WebGL context loss. However, based on the description above, it seems to me that the browser is going back and forth from from supporting it to not supporting it. Is this a larger issue at play with system configuration?

markschlosseratbentley avatar Sep 29 '23 15:09 markschlosseratbentley

@ezmobivietnam's latest repro steps make no mention of antialiasing.

Somebody please put together a single coherent set of repro steps and put them in the issue description.

pmconne avatar Sep 29 '23 15:09 pmconne

@pmconne , I have no idea how the antialiasSamples is set/managed in Pineapple. But I did some tests with Alex's sandbox then had the result as below:

  • Case 1: set vp.antialiasSamples = to 4 then got the error: Screenshot 2023-10-01 at 2 07 47 PM
  • Case 2: don't set vp.antialiasSamples, the sample works well : Screenshot 2023-10-01 at 2 09 57 PM

ezmobivietnam avatar Oct 01 '23 18:10 ezmobivietnam

@pmconne @markschlosseratbentley Any updates on this? Do you need something else to complete this investigation? He gets the error consistently using the Sandbox Alex provided.

simnorm avatar Oct 18 '23 20:10 simnorm

I fail to repro in Chrome and Firefox on Windows 11 and Ubuntu 22.04. This includes setting vp.antialiasSamples to a definitely unsupported value like 192. I have no access to a macbook to figure out why your WebGL implementation is failing when you set the number of antialias samples to a value it claims it supports. @markschlosseratbentley, do you?

pmconne avatar Oct 18 '23 21:10 pmconne

@pmconne @simnorm @ezmobivietnam I tried on a M1 MacBook Air and cannot reproduce, using Safari or Chrome. I edited vp.antialiasSamples to be a definitely unsupported value like 192 as well.

From earlier discussion on this issue, this particular MacBook has a GPU and integrated graphics. I am still unclear whether the issue happens only when integrated graphics are enabled. If so, I recommend configuring the device to use the GPU with the browser(s).

Also please make sure all browsers are up to date and all macOS system updates are installed.

markschlosseratbentley avatar Oct 19 '23 13:10 markschlosseratbentley

Hi @markschlosseratbentley ,

I have changed Chrome settings to enable/disable hardware acceleration, and tested the sandbox that Alex provided then got the result below:

  1. Use hardware acceleration when available = ON (default setting): the issue consistently happens
  2. Use hardware acceleration when available = OFF: the issue disappears.

Thanks so much for your help! Binh

ezmobivietnam avatar Oct 19 '23 15:10 ezmobivietnam