Bug 104347 - Coordinated Graphics: Remove the dependency of WebCoordinatedSurface::Handle from Coordinated Graphics.
Summary: Coordinated Graphics: Remove the dependency of WebCoordinatedSurface::Handle ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dongseong Hwang
URL:
Keywords:
Depends on: 100819
Blocks:
  Show dependency treegraph
 
Reported: 2012-12-07 00:15 PST by Dongseong Hwang
Modified: 2013-01-11 17:33 PST (History)
4 users (show)

See Also:


Attachments
Patch (29.07 KB, patch)
2012-12-07 01:31 PST, Dongseong Hwang
no flags Details | Formatted Diff | Diff
Patch (28.90 KB, patch)
2012-12-07 23:32 PST, Dongseong Hwang
no flags Details | Formatted Diff | Diff
Patch (28.88 KB, patch)
2012-12-09 18:32 PST, Dongseong Hwang
no flags Details | Formatted Diff | Diff
Patch (18.86 KB, patch)
2012-12-10 01:49 PST, Dongseong Hwang
no flags Details | Formatted Diff | Diff
Patch (18.93 KB, patch)
2012-12-11 17:38 PST, Dongseong Hwang
no flags Details | Formatted Diff | Diff
Patch (12.02 KB, patch)
2012-12-12 00:10 PST, Dongseong Hwang
dongseong.hwang: review+
dongseong.hwang: commit-queue-
Details | Formatted Diff | Diff
Patch (12.11 KB, patch)
2012-12-13 16:47 PST, Dongseong Hwang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dongseong Hwang 2012-12-07 00:15:51 PST
It is a preparation patch for Threaded Coordinated Graphics on WK1.

Currently, UpdateAtlas and CoordinatedImageBacking use WebCoordinatedSurface::Handle, but WebCoordinatedSurface::Handle can be used only IPC-based Coordinated Graphics.
So this patch removes the dependency of WebCoordinatedSurface::Handle from UpdateAtlas and CoordinatedImageBacking.

The constructor of WebCoordinatedSurface creates a handle implicitly and then destroys the handle as soon as sending the handle to UI Process.
External class cannot create WebCoordinatedSurface::Handle anymore, because we don't have the requirement of creating many handles.
Comment 1 Dongseong Hwang 2012-12-07 01:31:06 PST
Created attachment 178181 [details]
Patch
Comment 2 Dongseong Hwang 2012-12-07 23:32:28 PST
Created attachment 178342 [details]
Patch
Comment 3 Dongseong Hwang 2012-12-09 18:32:24 PST
Created attachment 178458 [details]
Patch
Comment 4 Dongseong Hwang 2012-12-09 18:36:55 PST
Comment on attachment 178458 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=178458&action=review

> Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.cpp:238
> +    m_releaseHandleTimer = adoptPtr(new Timer<WebCoordinatedSurface>(const_cast<WebCoordinatedSurface*>(this), &WebCoordinatedSurface::releaseHandleTimerFired));

This patch creates the timer lazily because a WebCoordinatedSurface instance in UI Process does not need to create the timer.
Moreover, the destructor of TimerBase has ASSERT(m_thread == currentThread()), so UI Process can fire the Assertion if WebCoordinatedSurface is destroyed in the compositing thread.
Comment 5 Noam Rosenthal 2012-12-09 22:27:28 PST
Comment on attachment 178458 [details]
Patch

I don't see the point in this.
You can remove the dependency of the Handle in CoordinatedImageBacking and UpdateAtlas by converting the handle in LayerTreeCoordinator and LayerTreeCoordinatorProxy.
I'd rather we don't add this kind of magic in the argument coders.
Comment 6 Dongseong Hwang 2012-12-09 22:43:53 PST
(In reply to comment #5)
> (From update of attachment 178458 [details])
> I don't see the point in this.
> You can remove the dependency of the Handle in CoordinatedImageBacking and UpdateAtlas by converting the handle in LayerTreeCoordinator and LayerTreeCoordinatorProxy.
> I'd rather we don't add this kind of magic in the argument coders.

My purpose is to share the same API with both IPC-base and Threaded Coordinated Graphics.

In the detail, Threaded Coordinated Graphics will use LayerTreeCoordinatorProxy also, although LayerTreeCoordinatorProxy will be refactored to extract subset of LayerTreeCoordinatorProxy that Threaded Coordinated Graphics needs.

If we convert the handle in LayerTreeCoordinator, we will have following code.
#if ENABLE(IPC_BASED_COORDIATED_GRAPHICS)
void LayerTreeCoordinatorProxy::updateImageBacking(CoordinatedImageBackingID, const WebCoordinatedSurface::Handle&);
#elif ENABLE(THREADED_COORDIATED_GRAPHICS)
void LayerTreeCoordinatorProxy::updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>);
#endif

If we cast the magic in ArgumentCoder, we can have the same API.
void LayerTreeCoordinatorProxy::updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>);

I think both have its own benefit. I think it's a matter of personal taste. Do you prefer the first option?
Comment 7 Noam Rosenthal 2012-12-09 22:48:31 PST
> If we cast the magic in ArgumentCoder, we can have the same API.
> void LayerTreeCoordinatorProxy::updateImageBacking(CoordinatedImageBackingID, PassRefPtr<CoordinatedSurface>);
> 
> I think both have its own benefit. I think it's a matter of personal taste. Do you prefer the first option?

I prefer it if there was some class that does the IPC-specific stuff, and not try to make everything magically work the same for IPC/threading, since it's not really 100% the same.

I prefer it if there was a supervisor/coordinator class that was shared between IPC/threading, and then a smaller "client" class that does the IPC-specific/threading-specific thing, which is where the handle conversion would take place.
Comment 8 Dongseong Hwang 2012-12-10 01:49:31 PST
Created attachment 178492 [details]
Patch
Comment 9 Dongseong Hwang 2012-12-10 01:50:22 PST
(In reply to comment #7)
> I prefer it if there was some class that does the IPC-specific stuff, and not try to make everything magically work the same for IPC/threading, since it's not really 100% the same.
> 
> I prefer it if there was a supervisor/coordinator class that was shared between IPC/threading, and then a smaller "client" class that does the IPC-specific/threading-specific thing, which is where the handle conversion would take place.

Ok, I understand.
Comment 10 Dongseong Hwang 2012-12-11 17:38:08 PST
Created attachment 178932 [details]
Patch
Comment 11 Dongseong Hwang 2012-12-11 17:38:28 PST
rebased to upstream
Comment 12 Noam Rosenthal 2012-12-11 22:15:26 PST
Comment on attachment 178932 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=178932&action=review

> Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h:125
> +
> +    // Only WebCoordinatedSurface in Web Process has this member.
> +    OwnPtr<Handle> m_handle;
> +    mutable OwnPtr<WebCore::Timer<WebCoordinatedSurface> > m_releaseHandleTimer;
> +
> +#ifndef NDEBUG
> +    enum Purpose {
> +        Producer,
> +        Consumer
> +    };
> +    // This member exists for only a debugging purpose. It is Producer in Web Process, while Consumer in UI Process.
> +    Purpose m_purpose;
> +#endif

This is not really needed.
You can do everything else in this patch without having this magically-released handle.
Comment 13 Dongseong Hwang 2012-12-11 23:27:26 PST
(In reply to comment #12)
> (From update of attachment 178932 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=178932&action=review
> 
> > Source/WebKit2/Shared/CoordinatedGraphics/WebCoordinatedSurface.h:125
> > +
> > +    // Only WebCoordinatedSurface in Web Process has this member.
> > +    OwnPtr<Handle> m_handle;
> > +    mutable OwnPtr<WebCore::Timer<WebCoordinatedSurface> > m_releaseHandleTimer;
> > +
> > +#ifndef NDEBUG
> > +    enum Purpose {
> > +        Producer,
> > +        Consumer
> > +    };
> > +    // This member exists for only a debugging purpose. It is Producer in Web Process, while Consumer in UI Process.
> > +    Purpose m_purpose;
> > +#endif
> 
> This is not really needed.
> You can do everything else in this patch without having this magically-released handle.

Ok, I'll remain createHandle(Handle&) public.
And remove Purpose enum.

Do I understand correctly what you mean?
Comment 14 Dongseong Hwang 2012-12-12 00:10:28 PST
Created attachment 178985 [details]
Patch
Comment 15 Noam Rosenthal 2012-12-13 07:19:00 PST
Comment on attachment 178985 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=178985&action=review

Note that I r+/cq- those patches. Please work with guys at #qtwebkit to make sure you submit those patches gradually without breaking anything.

> Source/WebKit2/ChangeLog:15
> +        CoordinatedImageBacking. Now CoordinatedLayerTreeHost treats with the
> +        Handle.

treats with the handles -> converts the handle to a WebCoordinatedSurface.

> Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp:118
> +    // If failing to send the message, try again in the next update.

If sending the message fails

> Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:45
> +    // FIXME: We need to find more elegant way.
> +    if (!m_client->createUpdateAtlas(m_ID, m_surface))
> +        m_surface.clear();

What's not elegant?
Comment 16 Dongseong Hwang 2012-12-13 16:35:21 PST
(In reply to comment #15)
> (From update of attachment 178985 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=178985&action=review

Thank you for review!
 
> Note that I r+/cq- those patches. Please work with guys at #qtwebkit to make sure you submit those patches gradually without breaking anything.

I'll ask jturcotte to review too.
 
> > Source/WebKit2/ChangeLog:15
> > +        CoordinatedImageBacking. Now CoordinatedLayerTreeHost treats with the
> > +        Handle.
> 
> treats with the handles -> converts the handle to a WebCoordinatedSurface.
> 
> > Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/CoordinatedImageBacking.cpp:118
> > +    // If failing to send the message, try again in the next update.
> 
> If sending the message fails

Thx.

> > Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:45
> > +    // FIXME: We need to find more elegant way.
> > +    if (!m_client->createUpdateAtlas(m_ID, m_surface))
> > +        m_surface.clear();
> 
> What's not elegant?

Currently, if we fail to create handle, the UpdateAtlas gives up drawing anything. The comment means that we can do more proactive handling..

How about changing comment like
// FIXME: Currently, if we fail to send the surface to UI Process, UpdateAtlas gives up drawing anything implicitly.
Comment 17 Dongseong Hwang 2012-12-13 16:47:01 PST
Created attachment 179375 [details]
Patch
Comment 18 Dongseong Hwang 2012-12-13 16:47:48 PST
Comment on attachment 179375 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=179375&action=review

> Source/WebKit2/WebProcess/WebPage/CoordinatedGraphics/UpdateAtlas.cpp:43
> +    // FIXME: Currently, if sending the message fails, UpdateAtlas gives up drawing anything implicitly.

Changed the comment.
Comment 19 Eric Seidel (no email) 2013-01-04 00:41:47 PST
Comment on attachment 178985 [details]
Patch

Cleared Noam Rosenthal's review+ from obsolete attachment 178985 [details] so that this bug does not appear in http://webkit.org/pending-commit.
Comment 20 Dongseong Hwang 2013-01-10 18:56:02 PST
jocelyn : as you mentioned http://webkit.org/b/102994#c14, we want that Qt WK1 reuse Coordinated Graphics.

This patch is needed for WK1 to reuse CoordinatedSurface. As noam mentioned #c15, I need your opinion on this project.
Do you think this patch can be landed?
Comment 21 Jocelyn Turcotte 2013-01-11 04:48:31 PST
(In reply to comment #20)
> jocelyn : as you mentioned http://webkit.org/b/102994#c14, we want that Qt WK1 reuse Coordinated Graphics.
> 
> This patch is needed for WK1 to reuse CoordinatedSurface. As noam mentioned #c15, I need your opinion on this project.
> Do you think this patch can be landed?

The patch looks good to me, nothing blasphemous here.
I'm okay with the general direction, just make sure that you track regressions and fix them in a reasonable delay.

I'm still not sure what's the status of the WebKit2 lockout, is this considered a trivial change or not?
Comment 22 Dongseong Hwang 2013-01-11 17:10:29 PST
(In reply to comment #21)
> The patch looks good to me, nothing blasphemous here.
> I'm okay with the general direction, just make sure that you track regressions and fix them in a reasonable delay.

I'm glad to hear you :) I'll do my best not to make regression. If so, I'll fix immediately.

> I'm still not sure what's the status of the WebKit2 lockout, is this considered a trivial change or not?

The term of trivial change is so ambiguous. IMO coordinated graphics is on WK2 by chance. It is not strange if coordinated graphics is on WK1 or Platform.
So it seems to be ok.
Comment 23 WebKit Review Bot 2013-01-11 17:33:46 PST
Comment on attachment 179375 [details]
Patch

Clearing flags on attachment: 179375

Committed r139525: <http://trac.webkit.org/changeset/139525>
Comment 24 WebKit Review Bot 2013-01-11 17:33:51 PST
All reviewed patches have been landed.  Closing bug.