PDA

View Full Version : bug in drawview.stroke() ?


rvhaasen
02-20-2009, 07:29 AM
Hi, i have the following problem:

When the stroke() is called repeatedly (from a drawview derived class), the application is increasing the CPU load. After some minutes 100% CPU is used on a single core cpu, and the browser is not responding anymore. Tested on firefox and iexplorer, using for OL 4.1.1 and OL 4.2.0. Flash 8.

The effect can be demonstrated with the following code:


<canvas debug="false">
<include href="utils/4.1.x_compatibility.lzx"/>
<class name="historyChart" extends="drawview" height="100" width="200">
<method name="redraw" > <![CDATA[
this.beginPath()
this.rect(0,0,100,100)
this.closePath()
this.stroke();
]]></method>
</class>
<view name="mainView" >
<historyChart name="chart"/>
<handler name="oninit">
this.del = new LzDelegate(this,"updateTimer");
LzTimer.addTimer(this.del,100);
</handler>
<method name="updateTimer">
chart.redraw();
LzTimer.resetTimer(canvas.mainView.del,100);
</method>
</view>
</canvas>



When the line "this.stroke()" is removed, the CPU load is not increasing,
therefore i do suspect this method.

Is this a bug? Is there a solution for this problem?

Rick

rajubitter
02-20-2009, 08:05 AM
You probably have to use chart.clear() before you call the redraw method. I'm not sure, but if I remember correctly the drawview "memorizes" all shapes which have been drawn so far, so the number of rectangles which will be drawn will increase with every round.

But Max might know more about that...

- Raju

rvhaasen
02-20-2009, 01:01 PM
i added the clear() before drawing and that solved the problem!

Many thanks Raju for the quick help!

Rick

rajubitter
02-20-2009, 02:02 PM
Actually I think the documentation should be better for drawview. It's hard to understand the logic behind the drawing API.

Have fun,
Raju