[OpenLayers-Trac] [OpenLayers] #3429: Problems with lib\openlayers.js in Firefox

OpenLayers trac-20090302 at openlayers.org
Fri Jul 22 14:50:45 EDT 2011


#3429: Problems with lib\openlayers.js in Firefox
---------------------+------------------------------------------------------
 Reporter:  jdege    |       Owner:     
     Type:  feature  |      Status:  new
 Priority:  minor    |   Milestone:     
Component:  general  |     Version:  2.8
 Keywords:           |       State:     
---------------------+------------------------------------------------------
 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.

-- 
Ticket URL: <http://trac.openlayers.org/ticket/3429>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer


More information about the Trac mailing list