fix: replace unstable ObjectKey(tileRenderer) with stable TileKey#2195
Open
braindamagedman wants to merge 1 commit intofleaflet:masterfrom
Open
fix: replace unstable ObjectKey(tileRenderer) with stable TileKey#2195braindamagedman wants to merge 1 commit intofleaflet:masterfrom
braindamagedman wants to merge 1 commit intofleaflet:masterfrom
Conversation
Member
|
Oo, thanks for this, we should've caught that. That's a useful debug text, we might add that to the example app. We need to make sure that this isn't preventing the tiles from changing when we actually do want the state to change, since we've had far too many issues there in the past, but I think your fix should be good. |
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.
Previously tiles were keyed with
ObjectKey(tileRenderer), butTileRendererinstances are recreated on every build. Because of that, the key was unstable even when the logical tile did not change. The root cause of this issue was introduced in commit182c4fc when unbounded horizontal scroll was introduced.
As a result, Flutter could not match the new widget with the existing element and treated the tile as a new widget. This led to repeated disposal and recreation of
_TileStateinstead of updating the existing state.The fix replaces that key with a stable
TileKeybased onTileImageidentity andpositionCoordinates. This preserves_TileStatefor the same rendered tile and avoids unnecessary remounting.Before:

After fix:

You can check simple code to reproduce before/after examples here:
https://github.com/braindamagedman/flutter_map/tree/test/tile-key