Skip to content

Plugin is causing high CPU usage #9

@b-caby

Description

@b-caby

This issue is for a:

- [x] bug report
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

  • Go to any implementation of Leaflet with Azure Map tiles (eg. this Azure Map Sample).
  • Check the tab CPU usage in the browser task manager (Shift+Escape on Chromium based browsers)
  • The CPU is at 100% continuously which affects both the browser and the system performance

Expected/desired behavior

The map should not be consistently use 100% of the browser CPU

Versions

Reproducible using the latest version of the plugin and the latest version of Leaflet (1.9.4 as of today)

Mention any other details that might be useful

Web Workers have been introduced in this PR on July 29, 2022 to fix the issue that setTimeout is not called when the tab is inactive.
The worker code contains this line of code while (Date.now() < before + delay) { }; which starts an infinite loop until the number of milliseconds defined in delay is elapsed. This infinite recursion is responsible for the high CPU usage.

I suggest to reimplement the web worker with a proper implementation.
I can make a PR to fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions