kylebarron / deck.gl-raster

deck.gl layers and WebGL modules for client-side satellite imagery analysis
https://kylebarron.dev/deck.gl-raster/
MIT License
85 stars 10 forks source link

Slow performance due to successive ProgramManager.addShaderHook calls #22

Closed kylebarron closed 4 years ago

kylebarron commented 4 years ago

I recently noticed some poor performance, especially when panning (and thus creating new RasterLayers, which I ended up being able to debug down to https://github.com/kylebarron/deck.gl-raster/blob/7a3e90efc3eb705657eb950a9f6da819322b763f/src/deckgl/raster-layer/raster-layer.js#L89-L95

While _getModel is run only once per layer, essentially on initialization, the default ProgramManager is shared by all deck.gl layers. This means that each new layer that's rendered as a sublayer of the TileLayer adds new hooks.

Therefore the shader hooks on the program manager end up increasing more and more:

image

It appears there isn't a general solution in luma.gl to only add once globally, so I'll just check in the programManager._hookFunctions.