Bug 13537

Summary: Canvex example starts rendering strangely after a while
Product: WebKit Reporter: Elliott Sprehn <esprehn>
Component: Layout and RenderingAssignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, gavin.sharp
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: Mac   
OS: OS X 10.4   
URL: http://canvex.lazyilluminati.com/83/play.xhtml
Attachments:
Description Flags
patch; tolerate 0 sizes without raising an exception hyatt: review+

Description Elliott Sprehn 2007-04-29 01:13:53 PDT
In some situations the rendering of the <canvas> on <http://canvex.lazyilluminati.com/83/play.xhtml> becomes corrupted. Resizing the canvas with the size links at the top of the page, which seems to reset the canvas buffer and start over generally corrects the rendering.

Steps to reproduce:
1. At the start walk directly forward until standing on the edge of the step out of the blue area and stop.
2. Hold the left arrow key and do a 360 degree spin.

Another Way:
1. From the start, turn and walk to the left and stop inside the doorway after the door as gone up.
2. Face the inside room area (away from the Firefox logo).
3. Rotate 360 degrees.

Some flickering may occur, and different parts of the canvas rendering area may become stuck displaying part of the level, while other parts keep changing.

The frame rate should also jump much higher after this.

The 360 degree spin isn't strictly required, and the bug can be produced by doing a partial spin as you walk over the step from the blue floored area in the middle of the room as well in other situations.

Can't produce this behavior in Opera 9 or Firefox 2, so it doesn't appear to be a bug in the JS.
Comment 1 Elliott Sprehn 2007-04-29 01:54:38 PDT
Reproducible in the latest nightly (Sun Apr 29 3:44:55 GMT 2007).
Comment 2 Alexey Proskuryakov 2007-05-01 03:15:57 PDT
Confirmed with r21199.
Comment 3 Darin Adler 2007-05-04 21:42:23 PDT
I've debugged this and determined that the problem is that Safari's canvas will throw an exception if drawImage arguments are no good. That's what the WhatWG specification says we should do <http://www.whatwg.org/specs/web-apps/current-work/#images>, but here in the Canvex example it's causing us to do a save() without a restore() and the clip is getting stuck.
Comment 4 Darin Adler 2007-05-04 22:10:28 PDT
Created attachment 14347 [details]
patch; tolerate 0 sizes without raising an exception
Comment 5 Alexey Proskuryakov 2007-05-04 23:47:44 PDT
See also: bug 11251.
Comment 6 Dave Hyatt 2007-05-06 19:27:04 PDT
Comment on attachment 14347 [details]
patch; tolerate 0 sizes without raising an exception

r=me
Comment 7 Darin Adler 2007-05-06 20:25:03 PDT
Sending        LayoutTests/ChangeLog
Deleting       LayoutTests/fast/canvas/drawImage-with-invalid-args-expected.checksum
Deleting       LayoutTests/fast/canvas/drawImage-with-invalid-args-expected.png
Sending        LayoutTests/fast/canvas/drawImage-with-invalid-args-expected.txt
Sending        LayoutTests/fast/canvas/drawImage-with-invalid-args.html
Sending        WebCore/ChangeLog
Sending        WebCore/html/CanvasRenderingContext2D.cpp
Transmitting file data .....
Committed revision 21280.