Bug 113657

Summary: SVGImage::nativeImageForCurrentFrame() does not work if using DontCopyBackingStore
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, kkinnunen, pdr, sabouhallawa, schenney, senorblanco, simon.fraser, zimmermann
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 113420    
Bug Blocks:    

Description Chris Dumez 2013-03-31 01:35:36 PDT
The current implementation of SVGImage::nativeImageForCurrentFrame() creates a temporary ImageBuffer, draw the SVG to it and then returns a pointer to the native image using:
ImageBuffer::copyImage(CopyBackingStore)->nativeImageForCurrentFrame();

Using CopyBackingStore here is suboptimal. However, DontCopyBackingStore does not work in this case, at least with Skia implementation. The reason for this is that the underlying SkBitmap pixels do not get copied when creating the new Image but the pixels get freed when the temporary ImageBuffer gets destroyed. Therefore, the returned native image has no valid pixel data.
Comment 1 Stephen Chenney 2015-01-08 08:36:18 PST
The Skia limitation is obviously not relevant any more, so maybe this can be fixed for other ports.

Even in Chromium, the Skia limitation is no longer a problem.
Comment 2 Ahmad Saleem 2023-09-21 09:33:06 PDT
https://searchfox.org/wubkat/source/Source/WebCore/svg/graphics/SVGImageForContainer.cpp#57

RefPtr<NativeImage> SVGImageForContainer::nativeImageForCurrentFrame()
{
    return m_image->nativeImageForCurrentFrame();
}

Do we need to keep this open?
Comment 3 Kimmo Kinnunen 2023-09-26 02:06:30 PDT
No, this is already fixed by "sinking" the imagebuffer into the native image, which does not incur a copy.