iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
615 stars 210 forks source link

Set antialiasSamples=4 crashes on Mac #6033

Open a-gagnon opened 1 year ago

a-gagnon commented 1 year ago

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

pmconne commented 1 year ago

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.

ezmobivietnam commented 1 year ago

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

pmconne commented 1 year ago

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.

a-gagnon commented 1 year ago

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?

ezmobivietnam commented 1 year ago

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 commented 1 year ago

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.

pmconne commented 1 year ago

@markschlosseratbentley @iTwin/itwinjs-core-display

markschlosseratbentley commented 1 year ago

@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.

ezmobivietnam commented 1 year ago

@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

markschlosseratbentley commented 1 year ago

@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?

pmconne commented 1 year ago

@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.

ezmobivietnam commented 1 year ago

@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:

simnorm commented 1 year ago

@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.

pmconne commented 1 year ago

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?

markschlosseratbentley commented 1 year ago

@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.

ezmobivietnam commented 1 year ago

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