When using texImage2D with an Image or Canvas as the source of the data, WebKit draws the underlying CGImage to a CGBitmapContext to get access to the pixels. The context is created with memory from fastMalloc(), and therefore undefined. When the CGImage being drawn contains transparency, this undefined data shows through, causing pixel junk in the resulting WebGL texture image.
There is no workaround for this; there is no way to affect the pixels of that CGBitmapContext in such a way that the pixel junk is cleared without also making the resulting texture opaque.
The patch is trivial (using calloc, or adding a memset, or CGClearRect, or similar to zero the bitmap context's data before drawing the image in imageToTexture() in WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp. I'm having trouble building WebKit though so I can't offer a tested patch.
This problem can be fixed by forcing the blend mode to kCGBlendCopy. Have a patch in my tree, but haven't yet worked out how to make a testcase.
Created attachment 44359 [details]
Comment on attachment 44359 [details]