Merge lp:~ivaldi/midori/drop-notify-uri into lp:midori

Proposed by André Stösel
Status: Merged
Approved by: Cris Dywan
Approved revision: 6313
Merged at revision: 6331
Proposed branch: lp:~ivaldi/midori/drop-notify-uri
Merge into: lp:midori
Diff against target: 27 lines (+0/-10)
1 file modified
midori/midori-view.c (+0/-10)
To merge this branch: bzr merge lp:~ivaldi/midori/drop-notify-uri
Reviewer Review Type Date Requested Status
Cris Dywan Approve
gue5t gue5t Approve
Review via email: mp+178436@code.launchpad.net

Commit message

Drop redundant notify::uri handler

Description of the change

midori_tab_set_uri is called twice on every uri change

first in "midori_view_load_committed", then in "webkit_web_view_notify_uri_cb"

since there is one special case handled in "midori_view_load_committed" I would recommend removing "webkit_web_view_notify_uri_cb"

To post a comment you must log in.
Revision history for this message
gue5t gue5t (gue5t) wrote :

I like the idea of removing duplicate code (and the patch itself is fine mechanically) but this makes me wary. I'd like to see either some testing (e.g. logging and examining exactly when the different codepaths get called in the course of browsing), history-digging (when and why did we end up with two codepaths for the same thing?), or webkit source code justifications to ensure that this doesn't change behavior in a subtle but buggy way. I realize I sound pretty harsh here but in my opinion details of when tab uris are set is an area in which I think discipline is warranted.

Or hopefully I'm not misunderstanding the description: did you already test before/after this a fair bit, and find load_committed to suffice to provide the same behavior even in cases where pages are interrupted (user hits stop), take ages to time out, or fail to load?

Sorry to rain on any parades, this is just the kind of thing where webkit docs aren't always clear and we would do really well to make sure we have it right. :)

review: Needs Information
Revision history for this message
Cris Dywan (kalikiana) wrote :

My first thought was: isn't this to ensure that either anchors or scripts using # update the page - it does seem to still work.
Example http://webkitgtk.org/reference/webkit2gtk/unstable/WebKitWebView.html

Revision history for this message
André Stösel (ivaldi) wrote :

Yeah, I tested it (I always do). In my tests "midori_view_load_committed" was always called before "webkit_web_view_notify_uri_cb".

I'm pretty sure it works without "webkit_web_view_notify_uri_cb", but feel free to test it yourself.

@ Christian
Anchors were the first things I tested ;)

PS: the other option is to drop midori_tab_set_uri from midori_view_load_committed

Revision history for this message
gue5t gue5t (gue5t) wrote :

Consulting webkit source has put all my concerns to rest. I put gdb breakpoints on the two entrypoints we have now and saw in the callstack that they were both from nearby in the webkit library, as the backtrace exerpts below indicate (note the shared frame #9):

notify_uri:
#7 0x00007fe372fb75c3 in g_object_thaw_notify () from /usr/lib/libgobject-2.0.so.0
#8 0x00007fe36e345b62 in ?? () from /usr/lib/libwebkitgtk-1.0.so.0
#9 0x00007fe36e8fe04d in ?? () from /usr/lib/libwebkitgtk-1.0.so.0

load_committed:
#7 0x00007fe372fb740b in g_object_notify () from /usr/lib/libgobject-2.0.so.0
#8 0x00007fe36e345aac in ?? () from /usr/lib/libwebkitgtk-1.0.so.0
#9 0x00007fe36e8fe04d in ?? () from /usr/lib/libwebkitgtk-1.0.so.0

So I dug into the webkit source to make sure they were in the same function:

void FrameLoaderClient::dispatchDidCommitLoad()
{
    if (m_loadingErrorPage)
        return;

    /* Update the URI once first data has been received.
     * This means the URI is valid and successfully identify the page that's going to be loaded.
     */
    g_object_freeze_notify(G_OBJECT(m_frame));

    WebKitWebFramePrivate* priv = m_frame->priv;
    g_free(priv->uri);
    priv->uri = g_strdup(core(m_frame)->loader()->activeDocumentLoader()->url().string().utf8().data());
    g_free(priv->title);
    priv->title = NULL;
    g_object_notify(G_OBJECT(m_frame), "uri");
    g_object_notify(G_OBJECT(m_frame), "title");

    g_signal_emit_by_name(m_frame, "load-committed");
    notifyStatus(m_frame, WEBKIT_LOAD_COMMITTED);

    WebKitWebView* webView = getViewFromFrame(m_frame);
    if (m_frame == webkit_web_view_get_main_frame(webView)) {
        g_object_freeze_notify(G_OBJECT(webView));
        g_object_notify(G_OBJECT(webView), "uri");
        g_object_notify(G_OBJECT(webView), "title");
        g_object_thaw_notify(G_OBJECT(webView));
        g_signal_emit_by_name(webView, "load-committed", m_frame);
    }

    g_object_thaw_notify(G_OBJECT(m_frame));
}

So we should be fine picking either and ignoring the other.

review: Approve
Revision history for this message
Cris Dywan (kalikiana) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/midori-view.c'
2--- midori/midori-view.c 2013-08-02 23:45:16 +0000
3+++ midori/midori-view.c 2013-08-03 20:15:33 +0000
4@@ -1471,14 +1471,6 @@
5 }
6
7 static void
8-webkit_web_view_notify_uri_cb (WebKitWebView* web_view,
9- GParamSpec* pspec,
10- MidoriView* view)
11-{
12- midori_tab_set_uri (MIDORI_TAB (view), webkit_web_view_get_uri (web_view));
13-}
14-
15-static void
16 webkit_web_view_notify_title_cb (WebKitWebView* web_view,
17 GParamSpec* pspec,
18 MidoriView* view)
19@@ -3500,8 +3492,6 @@
20 midori_view_download_requested_cb, view,
21 #endif
22
23- "signal::notify::uri",
24- webkit_web_view_notify_uri_cb, view,
25 "signal::notify::title",
26 webkit_web_view_notify_title_cb, view,
27 "signal::leave-notify-event",

Subscribers

People subscribed via source and target branches

to all changes: