RESOLVED FIXED 105803
[EFL][WK2] Regression(138462) Sometimes garbage in snapshots
https://bugs.webkit.org/show_bug.cgi?id=105803
Summary [EFL][WK2] Regression(138462) Sometimes garbage in snapshots
Viatcheslav Ostapenko
Reported 2012-12-27 11:26:42 PST
In EwkViewImpl::takeSnapshot surface created by cairo_image_surface_create_for_data is returned, but buffer is release on exit. Doc for cairo_image_surface_create_for_data here http://www.cairographics.org/manual/cairo-Image-Surfaces.html#cairo-image-surface-create-for-data says: "The output buffer must be kept around until the cairo_surface_t is destroyed or cairo_surface_finish() is called on the surface." It just keeps pointer internally to the provided image buffer. The data from buffer is copied only in WKImageCreateFromCairoSurface. Mostly it works because data is copied immediately after return from already deallocated memory block, but I don't think it is right.
Attachments
Patch (3.41 KB, patch)
2012-12-27 11:33 PST, Viatcheslav Ostapenko
no flags
Patch (4.18 KB, patch)
2012-12-27 13:28 PST, Viatcheslav Ostapenko
no flags
Patch for landing (4.20 KB, patch)
2012-12-27 17:58 PST, Viatcheslav Ostapenko
no flags
Viatcheslav Ostapenko
Comment 1 2012-12-27 11:33:52 PST
Chris Dumez
Comment 2 2012-12-27 11:55:07 PST
Comment on attachment 180812 [details] Patch Sadly you are right. Sorry I missed that. However, I really don't like that we are returning a WKType from our C++ API. How about using copyCairoImageSurface() from CairoUtilities.h instead so that we can keep returning a PassRefPtr<cairo_surface_t>?
Viatcheslav Ostapenko
Comment 3 2012-12-27 12:18:25 PST
(In reply to comment #2) > (From update of attachment 180812 [details]) > Sadly you are right. Sorry I missed that. However, I really don't like that we are returning a WKType from our C++ API. How about using copyCairoImageSurface() from CairoUtilities.h instead so that we can keep returning a PassRefPtr<cairo_surface_t>? Do you mean it should copy image data 2 times?
Chris Dumez
Comment 4 2012-12-27 12:22:19 PST
(In reply to comment #3) > (In reply to comment #2) > > (From update of attachment 180812 [details] [details]) > > Sadly you are right. Sorry I missed that. However, I really don't like that we are returning a WKType from our C++ API. How about using copyCairoImageSurface() from CairoUtilities.h instead so that we can keep returning a PassRefPtr<cairo_surface_t>? > > Do you mean it should copy image data 2 times? Right, it will copy the image data twice in the accelerated compositing case. But at least, we would respect layering and the method would be more directly reusable by our public API.
Viatcheslav Ostapenko
Comment 5 2012-12-27 13:28:26 PST
Kenneth Rohde Christiansen
Comment 6 2012-12-27 15:40:25 PST
Comment on attachment 180819 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=180819&action=review Nice idea, I like it > Source/WebKit2/ChangeLog:9 > + from it create cairo surface 1st and use surface image internal buffer I would add a comma after 'it'
Viatcheslav Ostapenko
Comment 7 2012-12-27 17:58:04 PST
Created attachment 180834 [details] Patch for landing
WebKit Review Bot
Comment 8 2012-12-27 18:46:26 PST
Comment on attachment 180834 [details] Patch for landing Clearing flags on attachment: 180834 Committed r138518: <http://trac.webkit.org/changeset/138518>
WebKit Review Bot
Comment 9 2012-12-27 18:46:31 PST
All reviewed patches have been landed. Closing bug.
Chris Dumez
Comment 10 2012-12-27 22:25:17 PST
Comment on attachment 180834 [details] Patch for landing View in context: https://bugs.webkit.org/attachment.cgi?id=180834&action=review > Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp:58 > + return newSurface; Shouldn't we call release() here?
Viatcheslav Ostapenko
Comment 11 2012-12-27 22:59:26 PST
Comment on attachment 180834 [details] Patch for landing View in context: https://bugs.webkit.org/attachment.cgi?id=180834&action=review >> Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp:58 >> + return newSurface; > > Shouldn't we call release() here? Not necessary. I see that a lot of code use it this way with release, but it works fine without it. newSurface object will be deallocated in any case, but reference to the pointer will be kept by PassRefPtr object.
Chris Dumez
Comment 12 2012-12-27 23:18:17 PST
Comment on attachment 180834 [details] Patch for landing View in context: https://bugs.webkit.org/attachment.cgi?id=180834&action=review >>> Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp:58 >>> + return newSurface; >> >> Shouldn't we call release() here? > > Not necessary. I see that a lot of code use it this way with release, but it works fine without it. newSurface object will be deallocated in any case, but reference to the pointer will be kept by PassRefPtr object. I know it is not strictly required but it is still good practice to call release() here. By not calling release() you're uselessly ref'ing (when the PassRefPtr is constructed) and then unref'ing (when the RefPtr goes out of scope). I still believe it should be done properly.
Note You need to log in before you can comment on or make changes to this bug.