flowmap.gl icon indicating copy to clipboard operation
flowmap.gl copied to clipboard

DataProvider does not work with web worker

Open shadow-identity opened this issue 8 months ago • 0 comments

Hi there and thanks for sharing this amazing library

I have a question tho. I'm trying to put the data provider into a web worker, but I have the following error. Then I've tried to use the example from examples/react-worker-app, but got the same error.

Could it be that some API was changed so it does not work with workers anymore?

comlink.ts:636 Uncaught (in promise) DataCloneError: Failed to execute 'postMessage' on 'MessagePort': (layersData) => {
          this.setState({ layersData, highlightedObject: void 0 });
        } could not be cloned.
    at comlink.ts:636:8
    at new Promise (<anonymous>)
    at requestResponseMessage (comlink.ts:630:10)
    at Object.apply (comlink.ts:530:14)
    at FlowmapLayer.updateState (FlowmapLayer.ts:267:22)
    at FlowmapLayer._update (layer.ts:944:14)
    at FlowmapLayer._initialize (layer.ts:886:10)
    at LayerManager._initializeLayer (layer-manager.ts:339:13)
    at LayerManager._updateSublayersRecursively (layer-manager.ts:303:16)
    at LayerManager._updateLayers (layer-manager.ts:258:10)

In Firefox the traceback is similar

Uncaught (in promise) DOMException: Function object could not be cloned.
    requestResponseMessage comlink.ts:613
    requestResponseMessage comlink.ts:601
    apply comlink.ts:504
    updateState FlowmapLayer.ts:267
    _update layer.ts:944
    _initialize layer.ts:886
    _initializeLayer layer-manager.ts:339
    _updateSublayersRecursively layer-manager.ts:303
    _updateLayers layer-manager.ts:258
    setLayers layer-manager.ts:206
    updateLayers layer-manager.ts:218
    _onRenderFrame deck.ts:1032
    onRender animation-loop.js:269
    _renderFrame animation-loop.js:370
    redraw animation-loop.js:191
    renderFrame animation-loop.js:297
    requestAnimationFrame2 request-animation-frame.js:5
    _requestAnimationFrame animation-loop.js:355
    _startLoop animation-loop.js:303
    startPromise animation-loop.js:168
    promise callback*start animation-loop.js:164
    Deck deck.ts:383
    createDeckInstance deckgl.ts:98
    DeckGL deckgl.ts:202
    React 7
    workLoop scheduler.development.js:266
    flushWork scheduler.development.js:239
    performWorkUntilDeadline scheduler.development.js:533
    js scheduler.development.js:571
    js scheduler.development.js:633
    __require chunk-5WWUZCGV.js:8
    js index.js:6
    __require chunk-5WWUZCGV.js:8
    React 2
    __require chunk-5WWUZCGV.js:8
    js React
    __require chunk-5WWUZCGV.js:8
    js React
    __require chunk-5WWUZCGV.js:8
    <anonymous> react-dom_client.js:38

shadow-identity avatar Apr 24 '25 13:04 shadow-identity