question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deck.gl assertion failed uncaught exception is crashing the UI when specifying a customLayer

See original GitHub issue

Hi, I spent a chunk of time digging into what was happening. For some context I’m rendering DeepMap elements into the UI via the customLayers prop on the LogViewer. I followed the documentation here to add a new layer (i.e. new GeoJSONLayer). However, I noticed that sometimes a really obscure and seemingly random bug happens, where deck.gl asserts that a layer doesn’t have any state when it does. That layer happens to be the customLayer that I added.

When debugging, I noticed that deck.gl is trying to loop through layers and initialize them, in the middle of a ROSBag playback. All of the xvis layers needed to be initialized ( as in I inspected them all while debugging and they didn’t have a state ), however not the GeoJSONLayer, because its added separately (I believe).

What should I do to fix this?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
ryanjduffycommented, Dec 2, 2020

I encountered a similar error so I’m sharing my workaround in case it is useful to others.

My analysis of the issue is that the streetscape layers are recreated frequently but the layers provided via customLayers are not. As a result, the LogViewer logic (or something downstream in deck.gl) tries to initialize the layers assuming they are new which works for the built-in layers but fails for custom layers.

In my case, this seems to throw when seeking to a point in the timeline in which the data doesn’t exist yet. When the data comes in, the layers are created and initialized and the error throws.

To work around this, I added a ready check that subscribes to log updates. If at any point I can’t retrieve the current frame, I clear the ready flag until I can and then recreate the layer. Seems to do the trick.

Here’s the bulk of the hook I’m using:

function useMapLayer (geoJsonUrl?: string, log?: XVIZLoader) {
  const [layerData, setLayerData] = useState();
  const [ready, setReady] = useState(false);

  useEffect(() => {
    if (!log) return;

    function checkReady () {
      const frame = log?.getCurrentFrame();
      setReady(frame != null);
    }

    log.subscribe(checkReady);
    return () => log.unsubscribe(checkReady);
  }, [log, setReady]);

  useEffect(() => {
    if (!geoJsonUrl) return;

    fetch(geoJsonUrl)
      .then(res => res.json())
      .then(setLayerData);
  }, [geoJsonUrl, setLayerData]);

  return useMemo(() => ready && layerData && createLayer(layerData), [ready, layerData]);
}
3reactions
jruddellcommented, Sep 13, 2019

@twojtasz Any update on this? Its a frequent bug that requires a restart of the system, would like to see what we can do to get it fixed 😃 Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Deck.gl assertion failed uncaught exception is crashing the UI ...
For some context I'm rendering DeepMap elements into the UI via the customLayers prop on the LogViewer. I followed the documentation here to ......
Read more >
Unable to create Deck.gl layers and overlay - Stack Overflow
Ok so the issue was with npm modules of deck.gl it was using loaders.gl so I installed it but it didn't work so...
Read more >
Upgrade Guide - deck.gl
deck.gl no longer crashes if one of the layers encounters an error during update and/or render. By default, errors are now logged to...
Read more >
mapbox-gl | Yarn - Package Manager
Mapbox GL JS is a JavaScript library for interactive, customizable vector maps on the web. It takes map styles that conform to the...
Read more >
CHANGELOG.md · Gitee 极速下载/Mapbox-GL-JS - Gitee.com
Fix bug causing overzoomed raster tiles to disappear from map #4567; Fix bug causing queryRenderedFeatures to crash on polygon features that have an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found