vagran / dxf-viewer-example-src

Source for dxf-viewer-example GitHub pages repository
MIT License
47 stars 27 forks source link

Worker: Unmatched message sequence: 1 #21

Open MadsHolten opened 5 months ago

MadsHolten commented 5 months ago

I am trying to use the viewer in an Angular app and it works as a charm. However, since I am loading rather large DXFs, I would like to use a web worker.

Here is the code that I use:

async load(url: string, fonts: any, cb?: any) {
    await this._dxfViewer.Load({
      url,
      fonts,
      progressCbk: cb?.bind(this),
      workerFactory: () => new Worker(
        new URL('./DxfViewerWorker.js', import.meta.url)
      )
    });
}

My DxfViewerWorker.js-file looks like this:

import {DxfViewer} from "dxf-viewer"

DxfViewer.SetupWorker()

When I try to load a file I get the following error: Unmatched message sequence: 1. What causes this error? My Angular app is set up to use web workers and I also successfully make use of them elsewhere.