Closed Bug 293267 Opened 20 years ago Closed 20 years ago

When called via onclick, canvas rendering is far slower than called via onload

Categories

(Core :: Graphics: Canvas2D, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jens.b, Assigned: vlad)

Details

(Keywords: perf)

Attachments

(3 files)

When drawing into a canvas, the speed heavily differs depending on the way the
function is invoked. onload rendering is okay, onclick/href="javascript:..." is
really slow. Is this a bug or the intended behaviour?
Keywords: perf
What may be causing this is that after initial loading the canvas seems to be
rendered to screen after every drawing call. But that should not happen during
javascript execution. Only when the script is finished should the canvas repaint
to screen again.
Whoops, this was a pretty big thinko in the implementation.  This patch speeds
up performance drastically for interactive renderings.	It's still going to be
slightly /slow/ until the rendering stuff gets a little deeper into our moz
rendering core, but you won't get to watch each individual circle paint.

As a side effect, this also fixes the bug 293544
holding-pointer-after-Release() issue.
Assignee: nobody → vladimir
Status: NEW → ASSIGNED
Attachment #183361 - Flags: review?(bzbarsky)
-    NS_IF_ADDREF(*canvas = mDOMCanvasElement);
-    return NS_OK;
+    return CallQueryInterface(mCanvasElement, canvas);

You probably need to nullcheck mCanvasElement first since CallQI isn't nullsafe.
Comment on attachment 183361 [details] [diff] [review]
massive canvas speedup patch

>Index: content/canvas/src/nsCanvasRenderingContext2D.cpp
> nsCanvasRenderingContext2D::GetCanvas(nsIDOMHTMLCanvasElement **canvas)
> {
>-    NS_IF_ADDREF(*canvas = mDOMCanvasElement);
>-    return NS_OK;
>+    return CallQueryInterface(mCanvasElement, canvas);

That will crash if mCanvasElement is null.  You need to explicitly set *canvas
to null in that case, and not CallQI.

>Index: content/html/content/src/nsHTMLCanvasElement.cpp
>+  NS_IMETHOD UpdateImageFrame ();

Nix space before '('.

>+nsHTMLCanvasElement::UpdateImageFrame ()

And here.

r+sr=bzbarsky with those fixed.
Attachment #183361 - Flags: superreview+
Attachment #183361 - Flags: review?(bzbarsky)
Attachment #183361 - Flags: review+
Comment on attachment 183361 [details] [diff] [review]
massive canvas speedup patch

a=shaver
Attachment #183361 - Flags: approval1.8b2? → approval1.8b2+
Checked in with CallQI and whitespace issues fixed.  One of these days I'll
remember that CallQI doesn't handle a null param...
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
confirmed, the difference is really unreal
testcase 1 went from 15 secs down to instant
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: