bug report and fix proposal for TypeError: this.layer is null

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

bug report and fix proposal for TypeError: this.layer is null

Balázs Bámer-2

Hi Developers,

 

We use OpenLayers V2.13.1 in several projects. It works well in most cases,

but in one case it throws

TypeError: this.layer is null

during loading layers. It occurs in FF and IE.

 

The error rises in OpenLayers.Tile.shouldDraw in line 228:

maxExtent = this.layer.maxExtent;

 

I have found a similar phenomenon here:

https://github.com/openlayers/openlayers/pull/1064/files

where one corrects the bug by not drawing the already destroyed tiles.

 

However, this solution does not corrects the root of the problem. My solution

below may be not optimal, too, since we do not have time to dig deep in the

event-based tile management architecture, but is probably closer. This

solution also prohibits a memory leak.

 

The problem occurs this way:

 

OpenLayers performs Map layout calculations. First it requests a tile (one WMS

layer with singleTile = true), it draws it, then it realises the viewport

layout is changed, and calls OpenLayers.Tile.destroy. This function makes the

Tile instance practically unusable by setting all important properties to

null. Further operations on this instance ar not feasible any more.

 

After it (probably after several other calculations) it calls

OpenLayers.TileManager.clearTileQueue to delete all tiles of this layer.

Since the queue contains tiles for all layers in a map, it checks each tile

if it belongs to the layer in question. This check takes place in line 441.

if (tileQueue[i].layer === layer) {

 

In our case, the layer property of the tile is null, so the invalidated tile

instance escapes from deleting. Later, in a new viewport layout step OpenLayers

wants to draw it, which is not possible any more.

 

My idea is to delete tile instances with layer===null, too:

if (tileQueue[i].layer === null || tileQueue[i].layer === layer) {

 

If we let them gather, and somehow OpenLayers won't draw them (as usually

there is no problem), they result in a memory leak.

 

Best regards:

 Balázs Bámer

GRINTEC GmbH

Anzengrubergasse 6, 8010 Graz, Austria

Tel: +43(316)383706-0

[hidden email]

http://www.grintec.com

 

FN 47845k Handelsgericht Graz

 


_______________________________________________
Dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-dev