Preview-Service Not Working in Production Environment (WebGL Context Lost Issue)

Hello,
I am building Speckle in a mono-repo environment.

In my local development environment, the preview-service works well.
However, in the actual service environment, the preview-service does not function properly, so I would like to ask for assistance.

Local Environment

  • OS: Windows 11 + WSL2 (Ubuntu 22)
  • GPU: NVIDIA RTX 3050
  • CPU & RAM: 4 cores / 8GB
  • Chrome Version: 143.0.7499.40

Service Environment

  • OS: AlmaLinux 9
  • GPU: Red Hat, Inc. Virtio 1.0 GPU
  • CPU & RAM: 4 cores / 8GB
  • Chrome Version: 142.0.744.134

It seems that the service is failing due to viewer rendering errors in the browser:

  • WebGL: INVALID_OPERATION: useProgram: program not valid
  • WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost

If there is any known solution or workaround, I would greatly appreciate your guidance.
The full error log is attached below.

{"level":"debug","time":"2025-12-08T02:53:19.113Z","component":"preview-service","msg":"Starting browser, located at \"/usr/bin/google-chrome-stable\", with the following arguments: [\"--no-sandbox\",\"--disable-setuid-sandbox\",\"--disable-dev-shm-usage\",\"--disable-session-crashed-bubble\"]"}
(node:27000) [DEP0174] DeprecationWarning: Calling promisify on a function that returns a Promise is likely a mistake.
(Use `node --trace-deprecation ...` to show where the warning was created)
{"level":"info","time":"2025-12-08T02:53:19.220Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","msg":"Picked up job {jobId} for {serverUrl}"}
{"level":"warn","time":"2025-12-08T02:53:19.332Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","err":{},"msg":"Page error"}
{"level":"info","time":"2025-12-08T02:53:19.357Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","err":{},"msg":"[GroupMarkerNotSet(crbug.com/242999)!:A0602100E4020000]Automatic fallback to software WebGL has been deprecated. Please use the --enable-unsafe-swiftshader (about:flags#enable-unsafe-swiftshader) flag to opt in to lower security guarantees for trusted content."}
{"level":"warn","time":"2025-12-08T02:53:19.849Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","err":{},"msg":"Page error"}
{"level":"info","time":"2025-12-08T02:53:19.849Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","err":{},"msg":"WebGL: INVALID_OPERATION: useProgram: program not valid"}
{"level":"warn","time":"2025-12-08T02:53:19.849Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","err":{},"msg":"Page error"}
{"level":"info","time":"2025-12-08T02:53:19.849Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","err":{},"msg":"WebGL: INVALID_OPERATION: useProgram: program not valid"}
{"level":"info","time":"2025-12-08T02:53:19.881Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","err":{},"msg":"WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost"}
{"level":"debug","time":"2025-12-08T02:53:19.881Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","msg":{},"msg":"THREE.WebGLRenderer: Context Lost."}
{"level":"warn","time":"2025-12-08T02:53:20.011Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","err":{},"msg":"Page error"}
{"level":"warn","time":"2025-12-08T02:53:20.011Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","err":{},"msg":"Page error"}
{"level":"info","time":"2025-12-08T02:53:20.011Z","component":"preview-service","payloadId":"45","jobPriorAttemptsMade":0,"jobId":"dce4r3wn66.3d334099e84929c011c7168786905b5d","serverUrl":"http://[IP]:[PORT]/projects/dce4r3wn66/models/3d334099e84929c011c7168786905b5d","status":"error","elapsed":0.791,"msg":"Processed job {jobId} with result {status}. It took {elapsed} seconds."}
{"level":"debug","time":"2025-12-08T02:53:44.489Z","component":"preview-service","msg":"Starting browser, located at \"/usr/bin/google-chrome-stable\", with the following arguments: [\"--no-sandbox\",\"--disable-setuid-sandbox\",\"--disable-dev-shm-usage\",\"--disable-session-crashed-bubble\"]"}

Hi @anjp0304

Judging by the flags you are passing
[\"--no-sandbox\",\"--disable-setuid-sandbox\",\"--disable-dev-shm-usage\",\"--disable-session-crashed-bubble\"]

and by your service environment which has GPU: Red Hat, Inc. Virtio 1.0 GPU, the preview-service is trying to run software rendering. As of this year, Google seems to have disabled automatic software rendering fallback.

I would suggest you try to add the --enable-unsafe-swiftshader flag when running on machines with no GPUs.

Cheers

Hi alex

Sorry for the late reply.

I tried your suggestion, but unfortunately, it didn’t work. I ended up solving the issue another way, as it turned out to be a combination of two problems:

  1. Failed to launch the browser process: Since there is no display, I installed xvfb to run it in a virtual display environment.
  2. WebGL Context Lost: Without a GPU, Chrome lost the WebGL context while rendering the model. After confirming that rendering worked fine in Firefox, I switched the preview image execution to Firefox.

The issue is now completely resolved. Thanks again for your help!