bernhard-42 / vscode-ocp-cad-viewer

A viewer for OCP based Code-CAD (CadQuery, build123d) integrated into VS Code
Apache License 2.0
99 stars 10 forks source link

Intermittent work / fail behavior of OCP CAD Viewer #110

Open WayneSherman opened 2 days ago

WayneSherman commented 2 days ago

Using

After following the installation instructions, when opening the auto created demo file "ocp_vscode_demo.py" the viewer pane intermittently does not initialize properly.

It behaves like an initialization race condition. Changing the way I load the file changes the timing and the failure frequency, e.g. opening a folder (workspace) which contains the demo file vs opening the demo file directly. When opening a folder the viewer fails to initialize most of the time, whereas when opening the file directly the viewer pane works most of the time. But both cases have intermittent work/fail behavior.

My test system is on the slow side (running in VirtualBox) so it probably is exposing this race condition where a faster system would not see it.

Originally posted by @WayneSherman in https://github.com/bernhard-42/vscode-ocp-cad-viewer/discussions/104

bernhard-42 commented 2 days ago

I found one problem that could be related to it. The viewer tries to respond to a resize window event and call viewer.resize when viewer is not ready initialized. Hence the viewer crashes and does not work properly any more. On fast machines, the viewer might be initialized before the resize event hits.

The fix is to check whether viewer is not null before responding on the resize event. But, I did not check this against a "slow system" - due to not having a slow system :-)