OpenLayers OpenLayers

Ticket #1390 (reopened bug)

Opened 5 months ago

Last modified 4 months ago

svg flicker at end of pan

Reported by: tschaub Assigned to: tschaub
Priority: minor Milestone: 2.7 Release
Component: Layer.Vector Version: 2.5
Keywords: Cc: seb@openplans.org
State: Needs More Work

Description (Last modified by tschaub)

This example demonstrates the problem:

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <style type="text/css">
        #map {
            width: 800px;
            height: 475px;
            border: 1px solid black;
        }
    </style>
    <script src="../lib/OpenLayers.js" type="text/javascript"></script>
    <script type="text/javascript">
        
        var map;
        var vectors;
        
        function init(){
            map = new OpenLayers.Map('map');
            var wms = new OpenLayers.Layer.WMS(
                "OpenLayers WMS", 
                "http://labs.metacarta.com/wms/vmap0",
                {layers: 'basic'}
            );

            vectors = new OpenLayers.Layer.Vector(
                "Simple Geometry",
                {
                    styleMap: new OpenLayers.StyleMap({
                        externalGraphic: "../img/marker-gold.png",
                        pointRadius: 10
                    })
                }
            );
            
            map.addLayers([wms, vectors]);
            
            var features = [];
            var x = -111.04;
            var y = 45.68;
            for(var i = 0; i < 10; i++){
                x += i * .5;
                y += i * .1;
                features.push(
                    new OpenLayers.Feature.Vector(
                        new OpenLayers.Geometry.Point(x, y)
                    )
                );
            }
            
            map.setCenter(new OpenLayers.LonLat(x, y), 5);
            vectors.addFeatures(features);
        };
        
    </script>
  </head>
  <body onload="init()">
    <div id="map"></div>
    <p>Use the pan buttons.  See flicker at end of animated pan.</p>
  </body>
</html>

Attachments

hacked.patch (1.8 kB) - added by tschaub on 02/25/08 17:18:45.
horrible
1390-r6386-A0.2.patch (0.7 kB) - added by ahocevar on 02/27/08 05:53:12.
second-reflow.patch (0.6 kB) - added by tcoulter on 04/07/08 12:10:56.
A second reflow block to ensure things are set back to visible.

Change History

02/25/08 15:28:46 changed by tschaub

  • summary changed from vml flicker at end of pan to svg flicker at end of pan.

02/25/08 15:29:26 changed by tschaub

Haven't really confirmed that r6169 caused it.

02/25/08 15:31:54 changed by tschaub

  • description changed.

And now I've confirmed that r6169 is not the cause.

02/25/08 16:24:39 changed by tschaub

  • owner changed from crschmidt to tschaub.
  • status changed from new to assigned.
  • state set to Review.

Ok, this gets rid of the problem (flicker at end of pan in FF). It seems right to me, but I'd like to get Pierre's eyes on it as well. I thought I could address this in the Tween code, but couldn't find the appropriate place there.

02/25/08 16:25:53 changed by tschaub

  • state changed from Review to Needs More Work.

Doesn't work after all.

02/25/08 16:29:47 changed by sbenthall

  • cc set to seb@openplans.org.

02/25/08 17:18:45 changed by tschaub

  • attachment hacked.patch added.

horrible

02/27/08 05:52:59 changed by ahocevar

  • state changed from Needs More Work to Review.

New patch 1390-r6386-A0.patch:

This one fixes the problem by forcing a reflow on Gecko browsers only (I found out that the same occurs in Gnome Epiphany, so I suspect all Gecko browsers are affected). If we do not enforce this reflow, the svg will not be hidden, i.e. the visibility: hidden style will not be applied.

If this patch is applied, one of the patches for #1392 should also be applied, otherwise dragging the map using the DragPan control will be painful.

02/27/08 05:53:12 changed by ahocevar

  • attachment 1390-r6386-A0.2.patch added.

02/27/08 05:59:37 changed by pgiraud

This seems a bit less hacky.

Where did you find documentation on that 'reflow' thing ?

02/27/08 06:11:34 changed by ahocevar

Pierre, I admit that this is somewhat hackish. But I spent ~5 hours searching for a solution to this one, and it really just happens because the visibility:hidden style will not be applied most of the time.

I found no documentation on this specific reflow issue. I tried many many ways to force Gecko to finally hide the svg, and the one in the patch is the least hackish one I could find.

02/27/08 14:20:34 changed by tschaub

  • state changed from Review to Commit.

So, we agree (after exhausting ourselves) that this is a reflow issue. Firefox (or any gecko based) does not always correctly reflow after setting display style to hidden on elements whose child elements contain SVG (setting display to hidden on the layer div displays the same problem). Further, it appears that this only happens when display is set to hidden in a window.setTimeout or setInterval call. There seem to be two workarounds (that correctly trigger a reflow):

  1. Set another style propertly after setting the display to hidden.
  2. Continue execution in a new thread (call window.setTimeout with 0 delay).

Weird.

I agree that Andrea's fix is less hackish. Thanks for the effort on this. If nobody else thinks there is a different issue here, or a better way to solve this, speak up.

Otherwise, this certainly improves things.

02/27/08 14:32:44 changed by ahocevar

  • status changed from assigned to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [6389]) "svg flicker at end of pan". Gecko-based browsers might not reflow svg if only style properties of dom elements are changed. Fixed by setting the scrollLeft property. r=pgiraud,tschaub (closes #1390)

04/07/08 12:10:21 changed by tcoulter

  • status changed from closed to reopened.
  • state changed from Complete to Needs More Work.
  • resolution deleted.

Reopening because there still seems to be a flicker in the WFS layer after the end of pan. See r6808 and the second-reflow.patch I've added to this ticket.

From the channel:

<CIA-7> openlayers: tcoulter * r6808 /sandbox/topp/vespucci/lib/OpenLayers/Layer/Vector.js: Adding another block to force a reflow after the style has been set to "visible." This successfully reduces the flicker within the WFS layer. Not sure how it affects other code, however, though I'd guess it'd be minimal.
<funky_c> crschmidt: Should I ticket this ^ at all?
<crschmidt> r6808
<oltrac> http://trac.openlayers.org/changeset/6808, at , by tcoulter: Adding another block to force a reflow after the style has been set to "visible." This successfully reduces the flicker within the WFS layer. Not sure how it affects other code, however, though I'd gu
<crschmidt> so you now force two reflows, instead of one?
<funky_c> Ya. The first reflow is because it's having a problem actually making things hidden.
 It seems like the same problem happens when trying to set things to visible.
 The hidden/visible changes happen so quickly that (I think) whatever's doing the svg rendering doesn't even flinch.
 And there's no jump.
* crschmidt nods
<crschmidt> Feel free to open a ticket; possibly just reopen 1390
<funky_c> k, will do.

04/07/08 12:10:56 changed by tcoulter

  • attachment second-reflow.patch added.

A second reflow block to ensure things are set back to visible.

04/07/08 18:04:39 changed by crschmidt

  • milestone changed from 2.6 Release to 2.7 Release.