visgl / deck.gl

WebGL2 powered visualization framework
https://deck.gl
MIT License
12.3k stars 2.09k forks source link

[Bug] Dropped frames / bad performance with controller #7186

Open hyperknot opened 2 years ago

hyperknot commented 2 years ago

Description

When using DeckGL with a Mapbox map (maplibre fork), the performance gets bad, there are lot of dropped frames in Chrome FPS meter (red lines). The overall interactivity feels very laggy / sluggish. I mean just panning around with a mouse.

Removing the DeckGL component around results in a super smooth, 60 FPS / no dropped frames behaviour. Chrome FPS meter confirms this, there are no dropped frames.

There are no layers, no state, no interactivity, just panning around with mouse:

    <DeckGL
      initialViewState={{
        longitude: 11,
        latitude: 45,
        zoom: 6,
      }}
      controller={true}
    >
      <Map
        mapLib={maplibregl}
        style={{ width: '100vw', height: '100vh' }}
        mapStyle="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
      />
    </DeckGL>

Note: if you are on bleeding edge hardware like M1 Macbooks this might not be visible. Try it on an older Macbook to see it happening.

Flavors

Expected Behavior

Performance should be the same as of using react-map-gl. There should be no dropped frames.

Steps to Reproduce

Bad performance code:

import Map from 'react-map-gl'
import maplibregl from 'maplibre-gl'
import DeckGL from '@deck.gl/react/typed'

export function TestBasic() {
  return (
    <DeckGL
      initialViewState={{
        longitude: 11,
        latitude: 45,
        zoom: 6,
      }}
      controller={true}
    >
      <Map
        mapLib={maplibregl}
        style={{ width: '100vw', height: '100vh' }}
        mapStyle="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
      />
    </DeckGL>
  )
}

Good performance code:

export function TestBasic() {
  return (
    <Map
      mapLib={maplibregl}
      style={{ width: '100vw', height: '100vh' }}
      mapStyle="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
      initialViewState={{
        longitude: 11,
        latitude: 45,
        zoom: 6,
      }}
    />
  )
}

I've just tested a pure code and it gets the same dropped frames / bad performance behaviour as with the Mapbox layer. So it's not related to the Mapbox layer, it seems to be coming from Deck GL. Code below:

const COUNTRIES =
  'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_50m_admin_0_scale_rank.geojson'

function Root() {
  return (
    <DeckGL
      controller={true}
      initialViewState={{
        latitude: 51,
        longitude: 0,
        zoom: 4,
      }}
    >
      <GeoJsonLayer id="base-map" data={COUNTRIES} />
    </DeckGL>
  )
}

Environment

Logs

Nothing displayed.

hyperknot commented 2 years ago

I tested the official examples:

So I suspect it has to be something with the controller: true part. Interestingly get-started/pure-js/mapbox works well while the basic version doesn't.

Pessimistress commented 2 years ago

I'm unable to reproduce this issue.

It's understandable if React causes some performance overhead. It's also a known issue that the second monitor of Mac suffers from WebGL performance degradation. However, I've never heard of any issue with the basic usage pattern. And as you have noted, the problem is not consistent across the examples.

Can you maybe try on a different computer?

hyperknot commented 2 years ago

I'm working on better examples for reproducing the issue. The results I got were confusing as the NE countries GeoJSON makes dropped frames with deck.gl on its own, so the examples listed weren't meaningful.

I'll try to get better minimal cases and report them here.