fix(core): getTooltip disappears when autoHighlight: true and interleaved: true in MapboxOverlay (deck.gl)#9889
Merged
felixpalmer merged 4 commits intovisgl:masterfrom Dec 5, 2025
Conversation
8 tasks
felixpalmer
approved these changes
Dec 5, 2025
Collaborator
felixpalmer
left a comment
There was a problem hiding this comment.
Thanks. Tested and the behavior is much better!
felixpalmer
pushed a commit
that referenced
this pull request
Dec 8, 2025
…aved: true in MapboxOverlay (deck.gl) (#9889)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #9599
Background
This PR seems to fix the issue in #9599 where tooltips disappear when
autoHighlightis set ininterleavedmode with MapBox.I am going to be honest, I produced this with heavy Claude Code collaboration - I can't really claim to understand deeply what's going on here.
That being said, I did a decent amount of testing, by tweaking the getting-started/mapbox example and running it locally against these changes.
I also checked whether both pieces of the solution seem to be essential to it, and they are. Take out the
.equalschange, or the lastViewport source change, and the fix stops working.Testing
With a tooltip added:
interleavedandautoHighlight: tooltip disappearsI also tested the "radio" example, since it seemed like the one place where it might matter where
onHovergets its viewport from. It worked before and after the fix.I also tried flinging the camera and then keeping the cursor still so that an object moves under it. That is now also improved, but still not perfect.
Claude Code also wrote a test. It fails without the fix, and passes with it. This is the failure without the fix:
Claude Code's explanation
Here's an explanation I managed to wrangle from Claude Code. Take it with a grain of salt, of course.
Claude Code summary
Fixes tooltip disappearing immediately when cursor stops moving with
autoHighlight: trueandinterleaved: truein MapboxOverlay.Root cause: When
autoHighlightis enabled, hovering triggerslayer.setNeedsRedraw()(layer.ts:1240) to render the highlight effect. This redraw callsonViewportChangewith a viewport from the render loop (widget-manager.ts:100-110). The problem is thatonHoverhad previously storedinfo.viewport(from picking) aslastViewport. These are different object instances even though the camera hasn't moved, causing the conditionviewport !== this.lastViewportto be true and incorrectly clearing the tooltip.Why interleaved mode: In interleaved mode, deck.gl hooks into the base map's render loop via
map.on('render', ...)(deck-utils.ts:97-99). Each render cycle callsafterRender, which callsdeck._drawLayersand creates a fresh viewport viaview.makeViewport()(deck-utils.ts:327). This new viewport instance triggersonViewportChangeimmediately after autoHighlight's redraw, causing the mismatch with the picking viewport stored inlastViewport.Why viewports differ: Picking retrieves viewports from
viewManager.getViewports()(deck.ts:737), which returns cached viewport instances. However, the render loop (especially in interleaved mode) creates new viewport objects viaview.makeViewport()(view-manager.ts:361). Even with identical camera parameters, these are different object instances, soviewport !== this.lastViewportevaluates totrue.Why autoHighlight: Without
autoHighlight, hover events don't trigger redraws. The tooltip appears and stays visible becauseonViewportChangeis only called when the camera actually moves. WithautoHighlight, every hover that changes the highlighted object forces a redraw via_updateAutoHighlight(layer.ts:1228-1241), which immediately triggers the false "camera moved" detection.The fix: Always update
lastViewportfrom the render loop inonViewportChange, and remove the viewport assignment fromonHover. This ensures viewport comparisons use a consistent source, correctly detecting only actual camera movement.Change List
tooltip-widget.tsupdated to useonViewportChangeas its source oflastViewportinstead ofonHover.