mapbox / mapbox/mapbox-gl-js

SourceEXpressionBinder.updatePaintArray this.expression.evaluate is not a function

Open
#12,814 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

I'm running into this nasty intermittent exception that gets thrown. I can't reliably reproduce it, and I can't even imagine how I'd go about setting up a minimal repro case, but I'm reporting it here so that the next person who hits it at least has something to google for.

mapbox-gl-js version: 2.13.0

browser: Chrome

Steps to Trigger Behavior

It's a pretty complex React app with quite a few layers. When you click on features in a certain layer, it updates the style to highlight the thing you clicked on etc etc. There's also feature-state updating on hover.

Maybe 1 time in 100 when you click, an exception is thrown:

mapbox-gl-dev.js:15439 Uncaught TypeError: this.expression.evaluate is not a function
    at SourceExpressionBinder.updatePaintArray (mapbox-gl-dev.js:15439:1)
    at ProgramConfiguration.updatePaintArrays (mapbox-gl-dev.js:15714:1)
    at ProgramConfigurationSet.updatePaintArrays (mapbox-gl-dev.js:15848:1)
    at FillBucket.update (mapbox-gl-dev.js:28111:1)
    at Tile.setFeatureState (mapbox-gl-dev.js:40275:1)
    at SourceFeatureState.initializeTileState (mapbox-gl-dev.js:40646:1)
    at SourceCache._tileLoaded (mapbox-gl-dev.js:42994:1)
    at VectorTileSource.done (mapbox-gl-dev.js:50296:1)
    at Actor.processTask (mapbox-gl-dev.js:39056:1)

Digging into the code a little bit, updatePaintArray is being called on a thing whose expression is { kind: 'constant, value: { r:0, g:0, b: 0, a: 1}. Which doesn't have an evaluate function, so...exception.

image

That doesn't really help me know what to do about it though.

This full call stack suggests that the trigger ultimately was a call to removeLayer() but maybe I'm misinterpreting that.

image

Any thoughts? Ideas? Workarounds? Simply suppressing the exception would be a pretty good outcome.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at SourceExpressionBinder.updatePaintArray and trace the call path through ProgramConfiguration.updatePaintArrays, FillBucket.update, Tile.setFeatureState, and SourceCache._tileLoaded, especially around removeLayer(). A fix is done when feature-state or layer-removal updates no longer call evaluate on the reported constant expression; the payload does not identify a reproducible test or source file.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.