Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] IconLayer not correctly disposing of Texture #9164

Open
7 tasks
felixpalmer opened this issue Sep 20, 2024 · 1 comment
Open
7 tasks

[Bug] IconLayer not correctly disposing of Texture #9164

felixpalmer opened this issue Sep 20, 2024 · 1 comment
Labels

Comments

@felixpalmer
Copy link
Collaborator

Description

IconLayer generates WebGL: INVALID_OPERATION errors when a layer is repeatedly added & removed. The use case is adding a custom layer on hover.

Visually the icon texture data is corrupted across all layers (not just the one rendering the hover), suggesting that we are holding onto memory we shouldn't be.

Screen.Recording.2024-09-19.at.17.06.56.mov

The following errors are repeatedly logged:

WebGL: INVALID_OPERATION: bindTexture: attempt to use a deleted object
WebGL: INVALID_OPERATION: generateMipmap: no texture bound to target

Flavors

  • Script tag
  • React
  • Python/Jupyter notebook
  • MapboxOverlay
  • GoogleMapsOverlay
  • CartoLayer
  • ArcGIS

Expected Behavior

No response

Steps to Reproduce

Modify the examples/website/icon/app.tsx:

import React, {useState} from 'react';
import {createRoot} from 'react-dom/client';

import DeckGL from '@deck.gl/react';
import {IconLayer} from '@deck.gl/layers';
import type {PickingInfo} from '@deck.gl/core';

type BartStation = {
  name: string;
  entries: number;
  exits: number;
  coordinates: [longitude: number, latitude: number];
};

const baseUrl = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/website/'

function App() {
  const [hovered, setHovered] = useState(null);
  const layer = new IconLayer<BartStation>({
    id: 'IconLayer',
    data: baseUrl + 'bart-stations.json',
    getColor: (d: BartStation) => [Math.sqrt(d.exits), 140, 0],
    getPosition: (d: BartStation) => d.coordinates,
    getSize: 40,

    // Atlas (always works)
    // iconAtlas: baseUrl + 'icon-atlas.png',
    // iconMapping: baseUrl + 'icon-atlas.json',
    // getIcon: (d: BartStation, info) => info.index % 2 ? 'marker' : 'marker-warning',

    // Packing
    getIcon: (d: BartStation, info) => {
      const icon = d.name.length % 2 ? 'icon-marker.png' : 'icon-warning.png';
      return {url: baseUrl + icon, width: 64, height: 64}
    },

    pickable: true,
		onHover: event => {
      setHovered(event.object);
    }
  });

  const hoverLayer = layer.clone({
    id: 'hover',
    data: hovered ? [hovered] : [],
    pickable: false,
    sizeScale: 1.5,
    visible: Boolean(hovered)
  });

  // Variant A: works
  // const layers = [layer, hoverLayer];

  // Variant B: get Texture errors & glitches
  const layers = hovered ? [layer, hoverLayer] : [layer];

  return <DeckGL
    initialViewState={{
      longitude: -122.4,
      latitude: 37.74,
      zoom: 11
    } as any}
    controller
    getTooltip={({object}: PickingInfo<BartStation>) => object && object.name}
    layers={layers}
  />;
}

export function renderToDOM(container: HTMLDivElement) {
  createRoot(container).render(<App />);
}

Environment

Logs

No response

@ibgreen
Copy link
Collaborator

ibgreen commented Sep 20, 2024

A possible reason is that textures are now immutable so resizing (via any method such as framebuffer.resize() etc) creates new textures. This means that if we hold on to textures separately we may end up referencing deleted textures.

donmccurdy added a commit to keplergl/kepler.gl that referenced this issue Oct 17, 2024
Add customMarkersId to support signed urls (#178)

* feat: added customMarkersId

* feat: set customMarkersId defaultValue to undefined

---------

Co-authored-by: Álvaro <[email protected]>

release 0.0.78 (#180)

Co-authored-by: Álvaro <[email protected]>

ColorRangeSelector: support noHexColumn (sc-417437) (#181)

Release 0.0.79 (#182)

PointLayer: always render hover layer for icons to workaround IconLayer bug (#183)

* PointLayer: always render hover layer for icons to workaround IconLayer issue

Workaround IconLayer issue [1], where temporary IconLayer with hovered feature corrupts
other IconLayers.

[1]: visgl/deck.gl#9164

* changelog update

release 0.0.80 (#184)

ci: build action (#185)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants