Ticket #3225 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

Missing return value in the Renderer.Canvas.drawFeature() method

Reported by: vog Owned by: crschmidt
Priority: minor Milestone: 2.11 Release
Component: Renderer.Canvas Version: 2.10
Keywords: performance, canvas, renderer Cc: m.pohl@…
State: Commit

Description

The attached patch provides a return value for the Renderer.Canvas.drawFeature() method. This is expected by the vector layer in order to determine whether the feature has or hasn't been rendered.

The patch is fairly simple, it always returns true. That way, the features won't be added to the "unrenderedFeatures" array of the vector layer.

Attachments

OpenLayers-Canvas-fix-drawFeature.patch Download (406 bytes) - added by vog 2 years ago.
provide return value for Renderer.Canvas.drawFeature()
3225.patch Download (1.2 KB) - added by tschaub 2 years ago.
return true if feature is drawn
openlayers-3225.patch Download (2.0 KB) - added by ahocevar 2 years ago.
3225.2.patch Download (4.2 KB) - added by tschaub 2 years ago.
keep track of pending redraws

Change History

Changed 2 years ago by vog

provide return value for Renderer.Canvas.drawFeature()

Changed 2 years ago by tschaub

This is a fairly major bug. It means that we're unnecessarily redrawing every feature with every call to moveTo (since we iterate through all unrenderedFeatures there). There is also this weird bit about returning undefined if no geometry and false if not rendered. I don't see where the difference is used, but I think it makes sense to follow suit here as well. If the difference is really not needed, we should do a strict === check for false before adding to the unrendered features object.

Changed 2 years ago by tschaub

return true if feature is drawn

Changed 2 years ago by tschaub

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

(In [11851]) Making it so the canvas renderer returns true after rendering a feature. This saves an extra draw for every moveTo. p=vog,me r=me (closes #3225)

Changed 2 years ago by ahocevar

  • status changed from closed to reopened
  • resolution fixed deleted

r11851 results in no features being drawn at all in the vector-features-with-test.html example.

Changed 2 years ago by ahocevar

  • state changed from Review to Needs More Work

Changed 2 years ago by ahocevar

Changed 2 years ago by ahocevar

  • state changed from Needs More Work to Review

Now tests pass and examples work again. Thanks for any review.

Changed 2 years ago by tschaub

Rather than add a property which may be used for other purposes, I think it makes sense to only keep track of what we need to know. Since the renderer doesn't lock itself (something we should revisit), it gets screwed up when there is a pending redraw and the last drawn feature in a batch has no geometry (this is the case that failed with r11851).

So, it makes more sense to me to keep track of whether there is a pending redraw. Then, in drawFeature, if rendered is false but pendingRedraw is true, we call redraw. This saves us from calling redraw whenever a feature with no geometry is added to the layer.

Changed 2 years ago by tschaub

keep track of pending redraws

Changed 2 years ago by tschaub

With the latest patch, the new tests pass and the above mentioned example works.

Changed 2 years ago by ahocevar

  • state changed from Review to Commit

Great improvement Tim, and thanks for the tests. Please commit.

Changed 2 years ago by tschaub

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

(In [11860]) Making the canvas renderer keep track of a pending redraw. With this change we properly redraw even if the last feature in a batch has no geometry. p=me,ahocevar r=ahocevar (closes #3225)

Note: See TracTickets for help on using tickets.