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

Info window is leaking #796

Closed
shedar opened this issue Dec 18, 2016 · 4 comments
Closed

Info window is leaking #796

shedar opened this issue Dec 18, 2016 · 4 comments

Comments

@shedar
Copy link

shedar commented Dec 18, 2016

Issue description

If you are using marker with a visible info window - CPU usage growth up to 100% of the core. Tested with Chrome.

Steps to reproduce and a minimal demo of the problem

http://plnkr.co/edit/q0ttx1XbTCnB4DFujtRV?p=preview

Steps to reproduce:

  1. Open Chrome task manager (Menu - More Tools - Task Manager)
  2. Check that CPU usage by plunkr is low and doesn't grow
  3. Click "toggle info" button (Info window should be shown after the click)
  4. Monitor CPU usage for 1 minute (you'll see it growth over time)
  5. (Optional) Click "toggle info" button again (CPU usage stays high even after info window is closed)

Current behavior

Marker with an open info window uses more and more CPU over time

Expected/desired behavior

Constant CPU usage

angular2 & angular2-google-maps version

2.1.1 & 0.16.0

Other information

@zuo305
Copy link

zuo305 commented Mar 16, 2017

yes. I found same issue.
And i using angular2 too.
The reason is when info window opend, the page would detect changed again and again, like a loop. So the page would redraw again and again. Hurry up. it is a big issue.

@rgupta2
Copy link

rgupta2 commented Mar 21, 2017

Any update/progress on this issue? @SebastianM

@mybluedog24
Copy link

mybluedog24 commented Nov 28, 2017

I found a solution here: https://github.com/angular/angular/issues/10883#issuecomment-240423378
So what I did is call the infoWindow.open()/close() outside of Angular to avoid change detections:

map.component.html

<div *ngFor="let property of _properties">
  <agm-marker [latitude]="property.Lat"
              [longitude]="property.Lng"
              [iconUrl]="_markerIconUrl"
              (mouseOver)="_infoWindowOpen($event, infoWindow);"
              (mouseOut)="_infoWindowClose($event, infoWindow);">
  </agm-marker>
</div>
...
<agm-info-window #infoWindow>
</agm-info-window>

map.component.ts

import { Component, OnInit, NgZone } from '@angular/core';
...
constructor(private _zone: NgZone) {...}
...
  private _infoWindowOpen(mouseEvent: any, infoWindow: any) {
    infoWindow.hostMarker = mouseEvent.marker;
    this._zone.runOutsideAngular(() => {
      infoWindow.open();
    });
  }
...
  private _infoWindowClose(mouseEvent: any, infoWindow: any) {
    this._zone.runOutsideAngular(() => {
      infoWindow.close();
    });
  }

remmeier added a commit to adnovum/angular-google-maps that referenced this issue Nov 30, 2017
extended mouse event with more information to allow to workaround the issue.
@stale
Copy link

stale bot commented Nov 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 13, 2018
@stale stale bot closed this as completed Nov 20, 2018
zsoltlengyelit pushed a commit to adnovum/angular-google-maps that referenced this issue Aug 5, 2019
extended mouse event with more information to allow to workaround the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants