Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix raster tiles flicker & hang #2211

Merged
merged 2 commits into from
Mar 2, 2016
Merged

Fix raster tiles flicker & hang #2211

merged 2 commits into from
Mar 2, 2016

Conversation

lucaswoj
Copy link
Contributor

@lucaswoj lucaswoj commented Mar 1, 2016

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Mar 1, 2016

6171a2f makes me think this might be the wrong solution.

@ansis
Copy link
Contributor

ansis commented Mar 1, 2016

This looks like the right solution! I think this broke with 4f99e94

@lucaswoj lucaswoj changed the title Fix raster tiles flicker / crash Fix raster tiles flicker & crash Mar 1, 2016
@lucaswoj lucaswoj changed the title Fix raster tiles flicker & crash Fix raster tiles flicker Mar 1, 2016
@lucaswoj lucaswoj changed the title Fix raster tiles flicker Fix raster tiles flicker & hang Mar 1, 2016
@lucaswoj lucaswoj force-pushed the raster-flicker-2201 branch 2 times, most recently from 90baedf to c33ad33 Compare March 1, 2016 23:10
@lucaswoj
Copy link
Contributor Author

lucaswoj commented Mar 1, 2016

@ansis I amended this PR to fix both bugs. :shipit:?

@ansis
Copy link
Contributor

ansis commented Mar 1, 2016

In what cases are tiles added to the cache while they are already in the cache? Is that a bug?

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Mar 1, 2016

It happened rarely during very fast zooms, probably due to a race condition. The LRU cache shouldn't get stuck in an infinite loop if the same key is added twice. We can debug the race condition separately. I want to get this out in a release ASAP.

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Mar 1, 2016

You're right. Reading the code, it is mysterious that this method could ever add the same tile twice.

this._cache.add(tile.coord.wrapped().id, tile);

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Mar 1, 2016

I have a hunch that the duplicate tiles have the same root cause as #1834. Our re-use of tiles across the dateline isn't perfect. Because the LRU cache uses wrapped coords but the tile pyramid doesn't, we might add duplicate entries for a wrapped coord.

@ansis
Copy link
Contributor

ansis commented Mar 1, 2016

Yeah, your hunch sounds right. I'll take a quick look to see if I can find something that regressed recently otherwise we can merge this to fix the fire and then properly fix it later.

@lucaswoj
Copy link
Contributor Author

lucaswoj commented Mar 1, 2016

Did you mention that we were (unintentionally) not using the cache at all until a recent fix?

@ansis
Copy link
Contributor

ansis commented Mar 1, 2016

Did you mention that we were (unintentionally) not using the cache at all until a recent fix?

We were using it, but only for the tiles at the current zoom. e6cb15c makes it look for parents too, which could have introduced this bug, or it could have just made it easier to hit.

@ansis
Copy link
Contributor

ansis commented Mar 2, 2016

Could this be it?

  • a tile across the dateline is need for the current view, addTile is called for it.
  • this does not return a tile because the tile has never been added for "world 0"
  • it gets added to this._tiles
  • you pan and now need the "world 0" version of that tile as well, call addTile for it
  • all the checks for existing tiles fail and it gets loaded instead of sharing the first version
  • you now have tiles in this._tiles that have distinct Tile objects but the same tile.coord.wrapped().id
  • both will be added to the cache with this wrapped id when they are removed

Ideally c33ad33 isn't needed but it is a safe fix. Merging now, releasing and then properly fixing later sounds good!

@lucaswoj lucaswoj merged commit c377a5e into master Mar 2, 2016
@lucaswoj lucaswoj deleted the raster-flicker-2201 branch March 2, 2016 00:18
@ryanbaumann
Copy link
Contributor

@lucaswoj @ansis
In version 0.15.0, the flicker and pan/zoom performance is improved.

However, I still notice flickering layers on Satellite maps with Map Pitch > 0 while panning, zooming, rotating on Chrome w/ Nvidia GTX680. Example below:

Video Example

JSFiddle

I only see the flicker on Satellite maps.

@ansis
Copy link
Contributor

ansis commented Mar 2, 2016

@ryanbaumann thanks for the video and jsfiddle. It looks like a different bug so I've opened a new issue: #2212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flickering of background layer when zooming Styles with raster tiles make the browser unresponsive
4 participants