Bug 39312

Summary: REGRESSION (r53686-r55990): Graphics corruption when watching video (affects youtube.com)
Product: WebKit Reporter: Adam Roben (:aroben) <aroben>
Component: MediaAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: cmarrin, enrica, eric.carlson, jer.noble, sfalken, simon.fraser
Priority: P2 Keywords: InRadar, PlatformOnly
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Windows XP   
URL: http://vimcasts.org/episodes/formatting-text-with-par/
Attachments:
Description Flags
dxdiag output for my machine
none
Picture of Safari drawing over the foreground application (Visual Studio)
none
Picture of Safari not repainting after being brought to the foreground
none
Fix an HRGN leak in WKCACFLayerRenderer darin: review+

Description Adam Roben (:aroben) 2010-05-18 13:05:05 PDT
To reproduce:

1. Go to http://vimcasts.org/episodes/formatting-text-with-par/
2. Click on the video to start it playing
3. Bring some other application in front of Safari
4. Wait

Eventually, Safari starts painting over the other application. If you then click on Safari to bring it to the front, Safari doesn't completely paint. There are various other bad symptoms that can be observed at this point (e.g., the system menu (obtained by right-clicking on the window's taskbar item) is all black). The only way to fix it is to quit and relaunch Safari.
Comment 1 Adam Roben (:aroben) 2010-05-18 13:06:18 PDT
I think this might be a regression caused by r59001.
Comment 2 Adam Roben (:aroben) 2010-05-18 13:06:54 PDT
Created attachment 56404 [details]
dxdiag output for my machine
Comment 3 Adam Roben (:aroben) 2010-05-18 13:07:22 PDT
<rdar://problem/7998728>
Comment 4 Adam Roben (:aroben) 2010-05-18 13:19:18 PDT
I tried to keep using Safari after this bug occurred, and it eventually crashed inside CGContextShowGlyphsWithAdvances. I'm not sure whether this is related.
Comment 5 Adam Roben (:aroben) 2010-05-18 13:20:04 PDT
Created attachment 56405 [details]
Picture of Safari drawing over the foreground application (Visual Studio)
Comment 6 Adam Roben (:aroben) 2010-05-18 13:20:26 PDT
Created attachment 56406 [details]
Picture of Safari not repainting after being brought to the foreground
Comment 7 Adam Roben (:aroben) 2010-05-19 07:46:31 PDT
The bug does not occur in Safari 4.0.5.

I saw this happen on youtube.com, too, with their HTML5 video player.

I tried running with the debug Direct3D runtime. Here's what I see in the debugger output window:

Direct3D9: (ERROR) :CreateRectRgn failed. Unable to accelerate Present.
Direct3D9: (ERROR) :BitBlt or StretchBlt failed in Present
D3D9 Helper: IDirect3DDevice9::Present failed: E_FAIL

This happened a few times, and then I hit an assertion in CGContextWithHDC:

    ASSERT(info.bmBitsPixel == 32);

info.bmBitsPixel is 52428, which just seems completely bogus.
Comment 8 Adam Roben (:aroben) 2010-05-19 09:48:15 PDT
I guess it's possible that this was caused by r53711 (which added hardware compositing for <video>) rather than r59001.
Comment 9 Adam Roben (:aroben) 2010-05-19 14:30:17 PDT
Bug reproduces in r56153.
Comment 10 Adam Roben (:aroben) 2010-05-19 15:01:41 PDT
I feel pretty confident that r53711 caused this, but unfortunately other bugs around that revision make it hard to test that theory.
Comment 11 Adam Roben (:aroben) 2010-05-20 08:47:40 PDT
Running with full page heap enabled doesn't give any extra information in this case.
Comment 12 Adam Roben (:aroben) 2010-05-20 13:37:35 PDT
Looks like we're leaking GDI objects like crazy when the video is playing. I think this could be the cause of the bug.
Comment 13 Adam Roben (:aroben) 2010-05-20 13:38:20 PDT
We also leak on the poster-circle demo. I wonder if the bug will occur if I leave that demo running long enough.
Comment 14 Adam Roben (:aroben) 2010-05-20 14:14:06 PDT
I'm testing to see whether the fix for bug 39443 fixes this bug, too.
Comment 15 Adam Roben (:aroben) 2010-05-20 14:14:59 PDT
With the fix for bug 39443, the video plays to completion without triggering any D3D errors or any graphics corruption. I'm going to dupe that bug to this one.
Comment 16 Adam Roben (:aroben) 2010-05-20 14:16:01 PDT
*** Bug 39443 has been marked as a duplicate of this bug. ***
Comment 17 Adam Roben (:aroben) 2010-05-20 14:22:54 PDT
Created attachment 56631 [details]
Fix an HRGN leak in WKCACFLayerRenderer
Comment 18 Adam Roben (:aroben) 2010-05-20 14:31:50 PDT
Committed r59864: <http://trac.webkit.org/changeset/59864>