Kitware / vtk-js

Visualization Toolkit for the Web
https://kitware.github.io/vtk-js/
BSD 3-Clause "New" or "Revised" License
1.24k stars 380 forks source link

[Bug] VTKJS is so slow on MAC #2962

Closed zuoPang closed 10 months ago

zuoPang commented 11 months ago

Bug description

When VTKJS renders a large grid, it is stuck on a specific MAC, and Threejs can be rendered smoothly. (1) Under the mac, Firefox and Safair can be rendered smoothly; (2) Chrome can also be rendered smoothly when the user-anonle = metal is opened.

Steps to reproduce

Load a large grid model casually and rotate the model in the scene. The performance is very stuck

Detailed Behavior

No response

Expected Behavior

Metal can be automatically used in the Mac environment

Environment

sysuyl commented 11 months ago

Similar problem on my mac(MacbookPro 2016) + Chrome.

Test link, threejs example demo: https://threejs.org/editor/ vtkjs example demo: https://kitware.github.io/vtk-js/examples/STLReader/index.html

Test mesh, about 300,000 faces

jourdain commented 11 months ago

Can someone provide a sample stl file?

sysuyl commented 11 months ago

hello, here is a test file. @jourdain nefertiti.zip

zuoPang commented 11 months ago

model.zip

https://github.com/Kitware/vtk-js/assets/151905221/da710ff7-9354-411c-9aec-b707e575308e

After loading the model, it cannot rotate normally and is very stuck.

jourdain commented 11 months ago

Just tried both models on Mac M1 with Safari and Chrome and everything was fine. Could you try Glance and see which GPU get used in your setup. You may have to force your GPU to be used.

Screenshot 2023-12-06 at 09 46 44
daker commented 11 months ago

@zuoPang @sysuyl can you do this test and see if it does solve the issue ? go to about:flags in Chrome, "Choose ANGLE graphics backend", and choose "Metal", restart the browser then do the test again

Chrome bug: crbug.com/1245448

zuoPang commented 11 months ago

@zuoPang @sysuyl can you do this test and see if it does solve the issue ? go to about:flags in Chrome, "Choose ANGLE graphics backend", and choose "Metal", restart the browser then do the test again

Chrome bug: crbug.com/1245448

This is OK, thank you, but I hope to find a way that you don't need to set the chrome setting manually. There is no good way to find a good way so far

zuoPang commented 11 months ago

Just tried both models on Mac M1 with Safari and Chrome and everything was fine. Could you try Glance and see which GPU get used in your setup. You may have to force your GPU to be used. Screenshot 2023-12-06 at 09 46 44

iShot_2023-12-07_10 52 04

It is normal to open the default, but when I open a large grid model, it is still very stuttering, I can’t use it normally. @jourdain

daker commented 11 months ago

it's a Chrome bug on MAC with AMD GPU and i don't think there is something to do unless Chrome changes the backend by default

zuoPang commented 11 months ago

it's a Chrome bug on MAC with AMD GPU and i don't think there is something to do unless Chrome changes the backend by default

Thank you, I think you are right, but there is still a problem that I haven't figured out yet. In the same environment, threejs behaves completely normally. I can't find out whether it has done anything to solve this problem.

sysuyl commented 11 months ago

Just tried both models on Mac M1 with Safari and Chrome and everything was fine. Could you try Glance and see which GPU get used in your setup. You may have to force your GPU to be used. Screenshot 2023-12-06 at 09 46 44

@jourdain hello, here is my mac shows, image

jourdain commented 11 months ago

@daker was spot on. Thanks for confirming the GPU spec.

sysuyl commented 11 months ago

I also want to know why Threejs can render smoothly.

jourdain commented 11 months ago

Threejs makes a different assumption than vtk.js. VTK is aimed at scientific visualization (support big mesh, off-center, interpolate before mapping, etc.), which generates more complex GL, which can be slower with some drivers/GPU.

sysuyl commented 11 months ago

Thanks @jourdain . I have indeed found that the rendering of some more complex applications based on Threejs on my Mac(+Chrome) is also quite sluggish. But the simple mesh rendering application is quite smooth.