mapbox-gl-js icon indicating copy to clipboard operation
mapbox-gl-js copied to clipboard

map.on("idle" is not firing in 3.17.0 (worked in 3.16.0)

Open jaybo opened this issue 2 weeks ago • 5 comments

mapbox-gl-js version

v3.17.0

Browser and version

Chrome 142.0.7444.176

Expected behavior

In v3.16.0, map.on("idle") fired appropriately.

Actual behavior

After upgrading to v3.17.0 (with no other code changes on my part), map.on("idle") never fires. Unfortunately, a simple example as in the link below doesn't demonstrate the issue, so it's some other weird interaction.

Link to the demonstration

https://codepen.io/jaybonomad/pen/pvyQqYZ?editors=1111

Steps to trigger the unexpected behavior

Unfortunately, I can't repro in a simple example.

Other info:

  • toolchain: Quasar / Vue / Typescript
  • using mapbox-draw
  • using custom layer
  • not setting repaint: true in options
  • map.isMoving() == false
  • map.isEasing() == false
  • map.isZooming() == false
  • map.isStyleLoaded() == true

Relevant log output


jaybo avatar Dec 07 '25 05:12 jaybo

Thanks for the report! Since we're not able to reproduce this on our end yet, we'd really appreciate if you could either continue trying to get a minimal reproducible test case, or alternatively bisect GL JS source in the repo between v3.16.0 and v3.17.0 (building GL JS at each step) to find the offending commit.

mourner avatar Dec 07 '25 11:12 mourner

Further investigations:

  • verified app otherwise runs normally if map.on("idle") is internally simulated.
  • removed custom layer and verified problem still exists.
  • verified it's not a yarn upgrade issue by nuking node_modules.

Where in mapbox-gl code is the idleevent triggered?

jaybo avatar Dec 07 '25 15:12 jaybo

@jaybo in the source, it's here: https://github.com/mapbox/mapbox-gl-js/blob/main/src/ui/map.ts#L4657

mourner avatar Dec 08 '25 10:12 mourner

If I repeatedly hit a breakpoint on line 4640 of map.ts:

const somethingDirty = this._sourcesDirty || this._styleDirty || this._placementDirty || averageElevationChanged;

all at some point become false, except _styleDirty which is always true.

jaybo avatar Dec 08 '25 21:12 jaybo

Bingo! Some years ago I added setTerrain(null), I think to get around this bug: https://github.com/mapbox/mapbox-gl-js/issues/10927 Now, if I remove the setTerrain(null) the idle event happens.

Pen updated to show the problem: https://codepen.io/jaybonomad/pen/pvyQqYZ?editors=1111

jaybo avatar Dec 08 '25 21:12 jaybo