I hit this issue with the media controls on iOS. They use a -webkit-canvas(name) for the background of an element. Later, when we want to paint into that, the reference to document is pointing to a different place than the context was created, even though the element is in the shadow DOM. I had to use ownerDocument to get it to work. This is also not always reproducible. It seems that if you try to paint into the context BEFORE you've caused a layout, everything works. See <rdar://problem/19923536> for more details.
<rdar://problem/19943135>
Fixing via the (ironically numbered) bug 144983
*** This bug has been marked as a duplicate of bug 144983 ***