Ticket #1910 (closed feature: worksforme)

Opened 6 years ago

Last modified 4 years ago

Invalid argument failure with IE8

Reported by: CharlesHarrison Owned by: crschmidt
Priority: blocker Milestone: 2.11 Release
Component: Layer.Vector Version: 2.7
Keywords: Cc:
State: Awaiting User Feedback

Description

Trying to load this website ...

 http://www.macfh.co.uk/JavaJive/AudioVisualTV/SatelliteTV/SatelliteCalculator.html

... in Internet Explorer 8 Beta v8.0.7000.0 gives the following error ...

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0) Timestamp: Sat, 17 Jan 2009 04:30:40 UTC

Message: Invalid argument. Line: 793 Char: 110 Code: 0 URI: http://openlayers.org/api/OpenLayers.js

The marker and line aren't drawn, making this webpage useless

Attachments

IE8_Generic_CSSPrefix_Selectors.patch Download (3.9 KB) - added by ahayes 6 years ago.
Replaces generic CSS selector prefix with explicit ones. Avoids errors and allows map to draw, but there are still problems.
vml.patch Download (1.0 KB) - added by crschmidt 5 years ago.
vml2.patch Download (1.0 KB) - added by madair 5 years ago.
openlayers-1910.patch Download (6.5 KB) - added by ahocevar 5 years ago.
set/get attributes without set/getAttribute

Change History

  Changed 6 years ago by crschmidt

  • milestone set to Future

Comments on  http://www.eggheadcafe.com/software/aspnet/31769152/vml-supported--or-bette.aspx indicate that VML support in IE8 is broken or buggy.

Patches to improve behavior are gladly accepted.

  Changed 6 years ago by ahayes

  • summary changed from Current Version Of OL Failis with IE8 Beta to Invalid argument failure with IE8

This is the offending line. Note that this is still a problem in the released version of IE 8, unless the page is running in IE7 compatibility mode.

style.addRule('olv\\:*', "behavior: url(#default#VML); " + "position: absolute; display: inline-block;");

  Changed 6 years ago by ahayes

It looks like the non-standard CSS "behavior" property has been changed to "-ms-behavior" in IE8 standards mode.

 http://msdn.microsoft.com/en-us/library/ms530723(VS.85).aspx

Changed 6 years ago by ahayes

Replaces generic CSS selector prefix with explicit ones. Avoids errors and allows map to draw, but there are still problems.

  Changed 6 years ago by ahayes

Well simply changing to -ms-behavior didn't work.

I then found two more leads:

From  http://code.google.com/p/explorercanvas/source/browse/trunk/excanvas.js

if (!doc.namespacesg_vml_?) {

doc.namespaces.add('g_vml_', 'urn:schemas-microsoft-com:vml',

'#default#VML');

And here is what MS has to say, which confuses me since 'behavior' is supposedly gone:

Generic CSS Prefix Selectors

Generic CSS prefix selectors are no longer supported in IE8 Standards Mode in order to provide standards-compliant CSS parsing. Most often, this affects pages trying to use CSS to attach behaviors to VML elements. This can cause a script error if set dynamically, or a silent failure when hard-coded into the CSS of a page. Ultimately the rule is not applied, leading to effects such as VML not displaying on a page. SOLUTION: Explicitly specify each tag name you want to match when using CSS prefix selectors. v\:* {

behavior: url(#default#VML);

}

v\:polyline, v\:line {

behavior: url(#default#VML);

}

Then I tried changing line 793 to this and the error goes away, the Google background and transparent WMS layers load, but I have no points on it yet:

if(!document.namespaces.olv){document.namespaces.add("olv",this.xmlns);var style=document.createStyleSheet();style.addRule('olv\\:shape',"behavior: url(#default#VML); "+"position: absolute; display: inline-block;");}

I looked through OpenLayers.js for all the possible olv\\:* possibilities and put them all in. Looks like maybe shape, rect, oval, fill, stroke, imagedata, and group. Any others that I might have missed in my search?

Anyway, now I have my points showing up and I can hover/click on them - but they are ovals and mis-positioned SE of where they ought to be. At this point, I'm wondering if someone else who knows what might be going on with projection could pick up the torch.

I have attached the patch.

  Changed 6 years ago by CharlesHarrison

Could this be relevant?

 http://code.google.com/apis/maps/documentation/index.html#XHTML_and_VML

I did try adding ...

xmlns:v="urn:schemas-microsoft-com:vml"

... but on its own it didn't seem to make any difference.

  Changed 6 years ago by ahayes

Yeah. I've been trying variations on setting that and the #default#VML when adding the namespace, as well as explicitly setting the whole list of elements and sub-elements from the VML docs on MSDN. I have been seeing changes in behaviour as I muck about though. Someone who knows the code better (at all really) might have an easier time guessing at what's going on.

I apologize too. I should have been working with (and patching) lib/OpenLayers/Renderers/VML.js

  Changed 6 years ago by ahayes

Just tried Tim's suggestion from the list. I reverted to 2.7 and I added the following before the OpenLayers.js script tag:

<script type="text/javascript">

if(document.namespaces == null){

document.createElement('namespaces');

}

</script>

I was back to the original error.

I know the IE8 team made made a lot of changes between the Betas and RC1, and then some more last minute changes that weren't in the RC1. I suspect a lot of the suggestions out there are out of date as they refer to Beta or RC versions.

Changed 5 years ago by crschmidt

  Changed 5 years ago by crschmidt

The attached patch is my interpretation of what the existing patch is trying to do. Patching the singlefile build is really not a good idea; patch the source files and then use the build tool instead:

 http://docs.openlayers.org/library/deploying.html#building-the-single-file-build

  Changed 5 years ago by crschmidt

  • milestone changed from Future to 2.9 Release

follow-ups: ↓ 11 ↓ 15   Changed 5 years ago by tschaub

Can someone provide a simple example that fails in IE8? I'm trying the examples we ship with and not seeing a problem yet.

in reply to: ↑ 10   Changed 5 years ago by ahayes

Replying to tschaub:

Can someone provide a simple example that fails in IE8? I'm trying the examples we ship with and not seeing a problem yet.

Hi Tim. Are you trying in IE8 standards mode or have the examples been modified with the DOCTYPE that tells IE8 to run in IE7 compatibility mode?

follow-up: ↓ 14   Changed 5 years ago by tschaub

I'm just running through the ol examples (none have IE specific meta tags). E.g. http://openlayers.org/dev/examples/stylemap.html

Works fine in IE8.

I'll gladly spend some time checking out something if someone can post a link to an example that doesn't work.

  Changed 5 years ago by ahayes

Have a look at  http://arcticbayatlas.ca/quest.html

With this example, if you are in compatibility mode, then IE8 will not handle the CSS properly. If you are in standards mode, IE8 is happy with CSS and you should get a box for the map and an error from IE. The attached patch solves the error and allows the features to be drawn, but then they show up a bit squashed and in the wrong spot.

in reply to: ↑ 12 ; follow-up: ↓ 18   Changed 5 years ago by d3w4rd

Replying to tschaub:

I'm just running through the ol examples (none have IE specific meta tags). E.g. http://openlayers.org/dev/examples/stylemap.html Works fine in IE8. I'll gladly spend some time checking out something if someone can post a link to an example that doesn't work.

Looks like you can add the following doctype to the stylemap example (or any other example that uses new OpenLayers.Layer.Vector(...)) to receive the error:

<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

and here is a more complete example, which gives me the error in IE8:

<!doctype html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        
        <script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script>
        <script type="text/javascript">
            var map = null;
            function init(){
                
                map = new OpenLayers.Map('map');
                var layer = new OpenLayers.Layer.WMS("OpenLayers WMS", "http://labs.metacarta.com/wms/vmap0", {layers:'basic'} );
                
                map.addLayer(layer);
                map.setCenter(new OpenLayers.LonLat(-80, 40), 5)
                 
                var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
                var vectorLayer = new OpenLayers.Layer.Vector("Simple Geometry", {style: layer_style});
                                
            }
        </script>
    </head>
    <body onload="init();">
        <div id="map" style="height: 300px; width: 400px;"></div>
    </body>
</html>

If I remove the doctype or use IE7 Compatibility mode the error goes away.

in reply to: ↑ 10   Changed 5 years ago by CharlesHarrison

Replying to tschaub:

Can someone provide a simple example that fails in IE8? I'm trying the examples we ship with and not seeing a problem yet.


My Google demo gives it. It's fairly simple, but you'll have to use your own Google key if you want to muck about with it:

 http://www.macfh.co.uk/Test/Google_with_OpenLayers.html

follow-up: ↓ 17   Changed 5 years ago by crschmidt

CharlesHarrison:

I think you missed the 'simple' part of his request :) However, the previous comment does explain, and  http://crschmidt.net/mapping/vf-xhtml-1239311271.html also demonstrates the problem: specifically, you have to have something that is valid XHTML strict in order to trigger the bug.

in reply to: ↑ 16   Changed 5 years ago by CharlesHarrison

Replying to crschmidt:

I think you missed the 'simple' part of his request :)


Well, it's a lot simpler than the Satellite Calculator page!

you have to have something that is valid XHTML strict in order to trigger the bug.


Mine is Valid XHTML Transitional, note ...

in reply to: ↑ 14 ; follow-up: ↓ 19   Changed 5 years ago by ahayes

If I remove the doctype or use IE7 Compatibility mode the error goes away.

If you remove the doctype, IE8 is running in IE8 Quirks mode. If you put a standards based doctype in, IE8 will run in IE8 standards mode by default. If you have changed your Compatibility View settings or enabled Compatibility View using the button beside the URL field, then you would be put into IE7 Standards mode. See  http://blogs.msdn.com/ie/archive/2008/08/27/introducing-compatibility-view.aspx and  http://msdn.microsoft.com/en-us/library/dd567845(VS.85).aspx

The point is, if you want to use web standards and put a doctype in your page, then by default, IE8 will not render OL content correctly. The patch on this bug at least allows the map to render, but vectors are skewed.

There are things you can do to your pages to force IE7 Compatibility View for your pages. See:  http://msdn.microsoft.com/en-us/library/cc817570.aspx

But when you are in Compatibility View, you loose all the benefits of IE8's much improved support for CSS 2.1. That's why it's important to me anyway.

in reply to: ↑ 18   Changed 5 years ago by CharlesHarrison

Replying to ahayes:

If I remove the doctype or use IE7 Compatibility mode the error goes away.

If you remove the doctype, IE8 is running in IE8 Quirks mode. If you put a standards based doctype in, IE8 will run in IE8 standards mode by default. If you have changed your Compatibility View settings or enabled Compatibility View using the button beside the URL field, then you would be put into IE7 Standards mode.

The point is, if you want to use web standards and put a doctype in your page, then by default, IE8 will not render OL content correctly. The patch on this bug at least allows the map to render, but vectors are skewed.

Ok, that's perhaps still a problem for OL, but at least thanks to this information I've been able to solve mine. I've simply republished the page telling IE8 users to press the compatibility button! I've just tried it, and it works. Thanks for this info! Although I could have done with it earlier, it's perhaps not so bad - very few visitors are using IE8 ... I wonder why ...

follow-up: ↓ 21   Changed 5 years ago by crschmidt

CharlesHarrison: You don't even have to do that. Just add the meta-tag:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>

This will force compatibility mode on.

in reply to: ↑ 20   Changed 5 years ago by CharlesHarrison

Replying to crschmidt:

CharlesHarrison: You don't even have to do that. Just add the meta-tag: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/> This will force compatibility mode on.


Yes, but that will still force it after the problem has been fixed, I'd rather just give the very small number of affected users appropriate advice until the problem is fixed.

Changed 5 years ago by madair

  Changed 5 years ago by madair

patch updated to include the 'textbox' element so that vector labels get placed correctly.

I'm not seeing the 'skewed' behaviour that Amos mentions but maybe I'm not looking for the right thing.

Testing with examples/vector-features-with-text.html with this patch applied looks like the only version that doesn't work is if the document mode is IE7 Standards, or at least that is what the IE8 debugger is telling me.

follow-up: ↓ 24   Changed 5 years ago by itbeyond

I have just installed V2 patch on my live system and the errors have gone however the vector layer does not work. I get no polys, lines or even image markers shown on ie8. It works fine with compatibility turned on but is a bit strange. All examples work as they do not specify a doc type. If you want a test URL try these: www.exploroz.com/shop - draw a box or click on the map of Oz and the page will redraw and should put a poly or point vector on the map. Or try  http://www.exploroz.com/Places/Directions.aspx from Sydney to Perth - system will compute the result however the lines and start/end markers will not work. If you turn on Compate mode it all works. David

in reply to: ↑ 23   Changed 5 years ago by itbeyond

Replying to itbeyond: I have just installed the emulate meta tag on the live system as there were way to many errors so the test url will not work please visit  http://www.exploroz.com/imapplot/geo.aspx as the Meta tag is not issued to this url. Sorry.

David

  Changed 5 years ago by pspencer

A bit more information for the record and another suggestion for the patch ...

OL 2.8 was not working with Fusion in IE 8, I applied the vml2 patch and now I don't get any errors. There was another problem that I am not entirely sure what to do with - all my interactively drawn vectors are scaled to fit in a specific area of the map, not the whole map. The problem comes from the use of setAttribute, see the following url for reference info:

 http://www.lrbabe.com/?p=104

Turns out that calling

root.setAttribute('coordsize', size)

in VML.js setExtent method was not setting the size. Following the conversation in the above link, it turns out that setAttribute cannot be used after a VML element has been appended to the DOM, you need to set it directly. So changing to

root.coordsize = size

does work (in all versions of IE including 8) and fixes my problem in Fusion. I don't think this shows up unless you resize the map container, which my Fusion test application was doing. I didn't see any other problems but I suspect that

this.root.setAttribute('coordorigin', org);

should also be changed to:

this.root.coordorigin = org;

I can update the patch with these changes but I am really not sure if they are the right changes to make (especially the coordorigin because I didn't try it).

  Changed 5 years ago by ahocevar

pspencer: setting attributes like this is totally valid in IE. Since the VML renderer is only used in IE, I'd say making this change is the right thing to do.

Changed 5 years ago by ahocevar

set/get attributes without set/getAttribute

  Changed 5 years ago by ahocevar

  • state set to Review

The above patch replaces all set/getAttribute statements with direct property access. I tested most vector examples in IE8 (with doctype set to <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN"> ) and IE7, and everything seemed to work.

In case we need another 2.8 RC, should we maybe include this? Either way, please review.

  Changed 5 years ago by crschmidt

  • milestone changed from 2.9 Release to 2.8 Release

I think there is a high return on fixing this, and it doesn't seem terribly high risk giving the reward. I'd say that this should be included in 2.8. I'll confirm with the mailing list before we do another RC.

  Changed 5 years ago by ksgeograf

I have tested this in IE8 (normal + compat mode) and IE6 with the latest fix, and it appears to work correctly. FF is not affected (as expected).

  Changed 5 years ago by madair

fixes most issues for me. The one thing is still a problem is feature labels in IE7 with the document in IE7 standards mode. labels do whow up in IE7 with the document in quirks mode so there is a work-around.

  Changed 5 years ago by crschmidt

Mike:

As I understand it, the problem you are having is in existence both before and after this patch, correct? so it's a complete nonsequitor with regard to this ticket?

  Changed 5 years ago by ahocevar

I can confirm that the non appearing labels in IE7 are unrelated to the patch proposed here. I created #2135 to track that.

in reply to: ↑ description   Changed 5 years ago by Quelbs

For me openlayers-1910.patch works fine and solves the problems with IE8. Thank you for the Patch!

  Changed 5 years ago by crschmidt

  • state changed from Review to Commit

With feedback from 5 different users of this code, and pretty significant testing, I think this makes senes to push in. Please comimt, and mark Pullup for 2.8.

  Changed 5 years ago by ngerber999

I know I posted on the mailing list, but just to make sure its logged with the ticket:

I have run tests using various versions of Internet Explorer using this patch

IE6 (XP): patch works fine, vectors render with labels IE7 (XP): patch works fine, vectors render but not with labels while in standards compliance mode IE8 (Vista): patch works fine, vectors render with labels

  Changed 5 years ago by ahocevar

  • keywords pullup added; IE8 invalid argument vector layer removed
  • state changed from Commit to Pullup

(In [9476]) Support for IE8 standards mode. Thanks ahayes, crschmidt, pspencer and madair, who all provided patches and valuable research to make this happen. r=crschmidt,ngerber999,Quelbs,ksgeograf (pullup #1910)

  Changed 5 years ago by crschmidt

  • keywords pullup removed
  • status changed from new to closed
  • state changed from Pullup to Complete
  • resolution set to fixed

(In [9478]) Pullup Changes for 2.8 RC6.

  • VML support for IE8 (Closes #1910)
  • Fix for Opera 9.27 support (Closes #2103)
  • Minor ArcXML change for exact renderer (Closes #2117)
  • Missing semicolons (Closes #2134)
  • vector labels in IE7 standards mode (Closes #2135)

  Changed 5 years ago by CharlesHarrison

  • status changed from closed to reopened
  • resolution fixed deleted

Loading calculator page where error originally first encountered, but now loading RC6, into same version of IE8 as first reported, in standards mode, there's now no error, but there's no vector marker either.

  Changed 5 years ago by ksgeograf

The page is fairly complex, could you provide some sample values for testing the page?

I just tried clicking the "Google maps" with all default values, and it appears to display a green marker and a green vector line. The display is the same in both FF and IE8.

  Changed 5 years ago by CharlesHarrison

Are you sure that you are in standards mode, not compatibility mode, and that you're not using a cached version of the page? I've just checked it again and it's the same, as is also the simpler demo page also linked above.

 http://www.macfh.co.uk/Test/Google_with_OpenLayers.html

  Changed 5 years ago by crschmidt

  • milestone changed from 2.8 Release to 2.9 Release

Charles,

I don't think that my message regarding 'simple' has reached you yet, I'm sorry about that. That page is not 'simple' for the purposes of reproducing a bug, so far as I can tell. for example:

  • It has multiple layers
  • It defines a new class
  • it creates draggable markers, etc.

There is also a lot of what looks like extraneous HTML and CSS in the page.

A better example of a simplified/minimized code is:

 http://crschmidt.net/mapping/popup/goog28.html

A quick and easy way to produce simplified examples like this is to take an existing example, strip extra unneccesary code, and republish that demonstrating the bug (this saves you from changing your code). I understand if you have no interest in doing this, but if you have no interest in doing this, it is unlikely that a developer will take interest in fixing your bug.

As it is, this is unlikely to be fixed in 2.8: It works in at least some situations, and not working in others can't really be a regression, since... it never worked.

follow-up: ↓ 45   Changed 5 years ago by ahayes

All of our vector maps that were not rendering in IE8 standards mode with 2.7 are now working properly with OL 2.8. Many thanks to crschmidt, ahocevar, and madair for getting this solved for the release! Fantastic!

Charles, as far as the error being reported in this bug, it's now gone. Might I suggest that this bug be closed again and a new bug opened with your new errors/symptoms?

Incidentally, I tried your site below under IE8 in *both* standards and compatibility mode and I can see and move the green marker & line in both. It also looks and behaves the same for me in Safari.  http://www.macfh.co.uk/Test/Google_with_OpenLayers.html

Have you tried clearing your caches, etc?

  Changed 5 years ago by tschaub

  • state changed from Complete to Awaiting User Feedback

  Changed 5 years ago by pgiraud

For the problem of 'no error but no markers', I just found that users (in fact administrators) can disable 'Binary and script behaviors' in the Security config in IE8 which gives the same unexpected results (ie. no VML drawn).

in reply to: ↑ 42   Changed 5 years ago by CharlesHarrison

Replying to ahayes:

Have you tried clearing your caches, etc?


I am no longer able to update IE8 as the beta version of W7 that I was using has expired, but that version still shows no marker, even though that test page now been updated to use 2.8 api rather the earlier rc. Yes I have cleared the cache, done a <Shift-Reload>, and checked that the source is the up-to-date one using 2.8 api.

... users (in fact administrators) can disable 'Binary and script behaviors' in the Security config in IE8 which gives the same unexpected results (ie. no VML drawn).


Binary and script behaviors is enabled.

  Changed 4 years ago by crschmidt

  • status changed from reopened to closed
  • resolution set to worksforme

At this point, I feel reasonably confident that "Invalid Argument" errors are only the result of attempting to create Vector layers before the DOM is ready. If someone can still recreate this error against a modern version of OpenLayers with IE, we can investigate why this might be happening. The example given here is not simplified, and has way too much code to figure out what might be going wrong.

In general, creating vector layers should happen onload. Trying to create them before that will typically result in strange or unwanted behavior.

ahayes reported 20 months ago that the test page provided worked for him. Checking in IE right now, it also works for me. With no reproducible bug condition or test case to work off of, there's not much we can do about this.

Note: See TracTickets for help on using tickets.