ui-leaflet icon indicating copy to clipboard operation
ui-leaflet copied to clipboard

bounds/center directives can get into an infinite digest loop

Open ezk84 opened this issue 9 years ago • 2 comments

Occasionally, if I have center.autoDistover == true and have bounds set on the map, I will get a $rootScope:infdig Infinite $digest Loop error.

This is something that I haven't been able to make reproducible, there appears to be something of a race-condition involved.

Looking at the last 5 watchers fired in the error, it seems that there is a sequence of center update, bounds update, center update, bounds update, etc.

I turned to the code and traced it a bit, and found at least one bug that could be related to this.

In /src/directives/bounds.js the bounds watcher and the boundsChanged event handler are guarded by flags scope.settingBoundsFromScope and scope.settingBoundsFromLeaflet, each of which get set in the other handler, so as to prevent an infinite loop.

The bug is that the scope variable refers to different scopes in the two handlers: in the boundsChanged event handler, it is pulled out of the event object and refers effectively to the scope of the leaflet directive, while scope in the bounds watcher is the scope passed to the link function (which is the parent of the leaflet scope).

I have this plunkr where I am attempting to reproduce the whole infinite loop. In the meantime, it may be worthwhile to check those flags out.

ezk84 avatar Mar 15 '16 09:03 ezk84

add a marker with autoPan:true and a large popover template height > 300px-ish, we have this infinite digest issue, and we can reproduce it by moving the map until a marker is nearly at the top of the map element, clicking the marker, which opens the popup, this causes the infinite loop to start.

dougrchamberlain avatar Aug 25 '17 16:08 dougrchamberlain

Did you find a fix? Thx

comapedrosa avatar Dec 07 '17 12:12 comapedrosa