Ticket #3429 (closed feature: duplicate)

Opened 22 months ago

Last modified 22 months ago

Problems with lib\openlayers.js in Firefox

Reported by: jdege Owned by:
Priority: minor Milestone:
Component: general Version: 2.8
Keywords: Cc:
State:

Description

Someone accidentally configured our test server to load the openlayers files individually. (The programmers usually load the individual files on their development machines, to make stepping through it in the debugger easier, but we are supposed to be loading the singleFile on the test and production servers).

In any case, one of the testers noticed a problem. We have a fairly complicated ASP.NET page, involving update panels, partial postbacks, embedded controls that are making periodic ajax calls, etc., and an OpenLayers map. When the page was loaded in the normal manner, everything worked fine. But if the page was refreshed – as in the user hit the browser’s “Reload” button, when the page returned the map wouldn’t draw completely. But only in Firefox. In IE8, IE9, Opera, and Chrome, after a page refresh everything worked fine. In Firefox 4.0.1 and in Firefox 5, after a page refresh, the map would be munged.

The degree of mungedness would differ, from one attempt to another. Sometimes no map would draw, sometimes the map layers would draw, but all of the controls would be missing. It was inconsistent.

I was able to reproduce this, on my dev machine, and examine the munged map in the DOM explorer. If the controls were missing, they were simply missing. It’s not that the controls’ divs were in the DOM, but the images weren’t drawing. The controls’ divs weren’t in the DOM.

Looking at the javascript errors made it clear what was happening: not all of the OpenLayers files were loading. And which were missing wasn’t consistent. Sometimes OpenLayers/Util.js would be dropped, in which case all of the OpenLayers code that was supposed to be drawing the map would error out, and the map wouldn’t draw at all. Sometimes OpenLayers/Feature.js would be dropped, and the raster layers would draw fine, but the vector layers would error out. Sometimes OpenLayers/Control.js would be dropped, and all of the controls would error out.

In every attempt, after a page refresh three or four of the files loaded by lib\OpenLayers.js would be dropped, and which they were would change. And this only after a page refresh, and never on initial load, or after a normal postback.

So I went looking at the code in lib\OpenLayers.js. After the jsfiles array is constructed, the code that actually emits the script tags has two alternative methods. If the browser is “MSIE” or “Safari”, the script tags are constructed as text, and emitted via document.write(). For all other browsers, the script tags are created as DOM objects via document.createElement(“script”), and appended to the head via appendChild().

Firefox had been using the DOM object method. I edited the file so that FireFox would use the document.write() method, that IE was using, and the issue went away. All of the files loaded successfully.

To me, this looks like a bug in FireFox. It seems to have a problem with that many script elements being added via appendChild(), after a page refresh.

It also looks like a fairly minor issue – nobody with any sense is going to use the lib\OpenLayers.js in a production configuration.

But it is an issue.

Change History

Changed 22 months ago by ahocevar

  • status changed from new to closed
  • resolution set to duplicate

Fixed in 2.11-rc1, duplicate of #2933

Note: See TracTickets for help on using tickets.