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

Cache temporary link for url resolution #8035

Merged
merged 1 commit into from
Mar 14, 2019
Merged

Cache temporary link for url resolution #8035

merged 1 commit into from
Mar 14, 2019

Conversation

mourner
Copy link
Member

@mourner mourner commented Mar 14, 2019

Closes #8032. Avoids unnecessary GC freezes when collecting unattached DOM objects by caching the link element for URL resolution. @poletani can you check if this fixes your issue?

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality we don't test browser-dependent methods
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

@mourner mourner requested a review from ryanhamley March 14, 2019 14:03
Copy link
Contributor

@ryanhamley ryanhamley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@ryanhamley
Copy link
Contributor

I think the underlying issue is that the anchor's href property was saved to an options object in geojson_source._updateWorkerData then a different property in the options object was used in dispatching the update to a worker. Since we reuse workers, it seems like the options object was never being garbage collected and in turn the <a> tags weren't being garbage collected. Either way, this should fix the issue.

@mourner
Copy link
Member Author

mourner commented Mar 14, 2019

@ryanhamley a.href is a string (a primitive value), so it shouldn't have any connection to the anchor. I think I misread the original report — the DOM object was indeed garbage collected, but not immediately because browsers prefer to do that in batches, and apparently if there were a ton of these objects to collect during a garbage sweep, it could cause micro-stutters.

@mourner mourner merged commit 6e50e15 into master Mar 14, 2019
@mourner mourner deleted the cache-resolve-url branch March 14, 2019 19:14
@poletani
Copy link
Contributor

@mourner unfortunately now I am unable to check it (I'll try later just to be sure), but it appears to me like the ideal solution. Thanks a lot for fixing it!

@poletani
Copy link
Contributor

@mourner I can confirm that the number of DOM nodes remains constant under the same test method, using the new fix.

@pakastin
Copy link
Contributor

pakastin commented Apr 2, 2019

Perfect, this was a huge issue for me! Great work! 👌

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.

The number of DOM nodes rises when setData(URL) is called frequenty
4 participants