Bug 107887

Summary: [Gtk] RunLoop::run shuold run current thread's run loop.
Product: WebKit Reporter: Seulgi Kim <dev>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: dev, d.nomiyama, dongseong.hwang, jaepark, mario, mrobinson, skyul, webkit.review.bot
Priority: P2 Keywords: Gtk
Version: 525.x (Safari 3.2)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Seulgi Kim 2013-01-24 17:42:35 PST
When off-the main thread use RunLoop with Timer, Timer doesn't fire callback.
Comment 1 Seulgi Kim 2013-01-27 20:55:10 PST
Created attachment 184933 [details]
Patch
Comment 2 Seulgi Kim 2013-01-27 21:40:37 PST
Created attachment 184936 [details]
Patch
Comment 3 Mario Sanchez Prada 2013-01-28 02:11:51 PST
Comment on attachment 184936 [details]
Patch

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

> Source/WebCore/ChangeLog:15
> +        No new tests. There is no case that uses RunLoop in off the main thread yet.

I guess you have some specific use cases for this change already in mind, and also that you probably have tested this manually in some way. If so, would you mind sharing those use cases / manual tests here? Also, I really think it would be worth trying to provide some kind of test along with this patch (probably an unit test).

I don't have much experience with this part of the code besides the implementation of modal dialogs in WebKit2GTK+, which I remember used this part of the code to control "modality" of the dialogs, so that's where my interest comes from.
Comment 4 Seulgi Kim 2013-01-28 02:48:52 PST
(In reply to comment #3)

Now my team is developing threaded model of coordinated graphics in Gtk (https://bugs.webkit.org/show_bug.cgi?id=100341).
And RunLoop is needed in compositor thread.
I'll share prototype sometime this week.
Comment 5 Mario Sanchez Prada 2013-01-28 03:03:18 PST
(In reply to comment #4)
> (In reply to comment #3)
> 
> Now my team is developing threaded model of coordinated graphics in Gtk (https://bugs.webkit.org/show_bug.cgi?id=100341).
> And RunLoop is needed in compositor thread.
> I'll share prototype sometime this week.

Thanks for the clarification and for sharing that prototype, that will be really useful to properly understand this in a better way.

BTW, I'm also adding Denis Nomiyama to CC here as he's working in something quite related to this and so he might be interested, I guess.
Comment 6 Seulgi Kim 2013-01-30 19:24:02 PST
I uploaded the prototype at https://github.com/DorothyBrowser/webkit/tree/threaded-compositor.
I welcome your comments.

Thank you.
Comment 7 Martin Robinson 2013-01-31 08:07:33 PST
Comment on attachment 184936 [details]
Patch

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

Looks pretty reasonable, but there is a memory leak in this new code, I think.

> Source/WebCore/platform/gtk/RunLoopGtk.cpp:35
>  #include <glib.h>
>  
> +#include <wtf/MainThread.h>
> +
>  namespace WebCore {

You should have these includes be all one block.

> Source/WebCore/platform/gtk/RunLoopGtk.cpp:40
> +    m_runLoopContext = isMainThread() ? g_main_context_default() : g_main_context_new();

g_main_context_default does not return a new reference while g_main_context_new does. You are leaking the new main loop here. You should do:

m_runLoopContext = isMainThread() ? g_main_context_default() : adoptGRef(g_main_context_new());
Comment 8 Seulgi Kim 2013-01-31 18:40:06 PST
Created attachment 185912 [details]
Patch
Comment 9 Martin Robinson 2013-02-07 18:08:02 PST
Comment on attachment 185912 [details]
Patch

Okay. This seem pretty reasonable.
Comment 10 WebKit Review Bot 2013-02-07 18:42:57 PST
Comment on attachment 185912 [details]
Patch

Clearing flags on attachment: 185912

Committed r142219: <http://trac.webkit.org/changeset/142219>
Comment 11 WebKit Review Bot 2013-02-07 18:43:02 PST
All reviewed patches have been landed.  Closing bug.