Merge lp:~evfool/midori/lp699970 into lp:midori

Proposed by Robert Roth
Status: Merged
Approved by: André Stösel
Approved revision: 6582
Merged at revision: 6707
Proposed branch: lp:~evfool/midori/lp699970
Merge into: lp:midori
Diff against target: 97 lines (+37/-0)
3 files modified
midori/midori-app.c (+22/-0)
midori/midori-tab.vala (+10/-0)
midori/midori-view.c (+5/-0)
To merge this branch: bzr merge lp:~evfool/midori/lp699970
Reviewer Review Type Date Requested Status
André Stösel Approve
Cris Dywan after-feature-freeze Approve
Review via email: mp+208947@code.launchpad.net

Commit message

This branch registers a handler to the network-changed signal of the GNetworkMonitor (which is already available, as midori already depends on GIO>=2.32.3, and GNetworkMonitor was introduced in 2.32), and in case a network is available (either connected to a network from an unconnected state, or switched to another network) reload all tabs from all browsers of midori.

Description of the change

This branch registers a handler to the network-changed signal of the GNetworkMonitor (which is already available, as midori already depends on GIO>=2.32.3, and GNetworkMonitor was introduced in 2.32), and in case a network is available (either connected to a network from an unconnected state, or switched to another network) reload all tabs from all browsers of midori.

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

I like the idea; though I think it definitely needs restricting, unconditional reloading would be very painful.

How about adding this to midori-tab.vala
enum LoadError { NONE, DELAYED, SECURITY, CRASH, NETWORK }
Set it like
midori_tab_set_load_error (MIDORI_TAB (view), MIDORI_LOAD_ERROR_NETWORK);
in webkit_web_view_load_error_cb
and reset it in midori_view_load_committed to NONE

The other suggested values aren't required for this one, I'm mentioning them for completeness if you'd like to add them as well I wouldn't mind, but just NONE and NETWORK would do.

review: Needs Fixing
Revision history for this message
Robert Roth (evfool) wrote :

That is a good idea, and not hard to implement, but it will only partially cover the bug, as the description says that "This could take me away from an error page to a website, or from an outdated website to an updated one.". This change will take you away from an error page, but an outdated website won't be updated. Maybe we could set some kind of threshold here? Do we know when a page was loaded? If yes, we can see how old that page is, and reload if older than the threshold.

Revision history for this message
Robert Roth (evfool) wrote :

Another problem I have found with your solution is that:
* i set the load error to none in load_committed
* i set the load error to network in load_error_cb
* on a load error, the load_error_cb sets the load error status correctly, however when displaying the error.html page, loading that also invokes load_committed (due to the webkit_web_view_load_alternate_html / webkit_web_frame_load_alternate_string call from midori_view_set_html), which resets the network load error status :(

Any ideas on how to work around this?

lp:~evfool/midori/lp699970 updated
6579. By Robert Roth

Only reload if load error is caused by network error

Revision history for this message
Robert Roth (evfool) wrote :

I have updated the branch with the changes you have requested, but it still needs fixing, as it doesn't work in this state, because of the issue mentioned in my previous comment.

lp:~evfool/midori/lp699970 updated
6580. By Robert Roth

Only reset the load error status if the loaded page is not a special page (lp:699970)

Revision history for this message
Robert Roth (evfool) wrote :

Ok, found it, updated the branch, so that I only reset the load error status in load committed if the page uri is the requested uri (the view is not a special view), which is not the case for the error page, so now only errored out pages are reloading.

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

That's looking nice. If you're okay with that it might be best to wait with this branch until the start of the next feature period since it may turn up unexpected behavior and we're going into freeze today.

review: Approve (after-feature-freeze)
Revision history for this message
Robert Roth (evfool) wrote :

I'm OK with that, no hurry. I will ping you after the next release to merge this.

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

There is a little bug:
- disable network
- load some page
- enable network
- page is reloading (works fine)
- disable network again
- page is reloading <- you stuck with the error page again

(i tested it with a static html, no js -> no background requests)

review: Needs Fixing
lp:~evfool/midori/lp699970 updated
6581. By Robert Roth

Merged from trunk

6582. By Robert Roth

Clear load error status on load started instead of on load committed (lp:699970)

Revision history for this message
Robert Roth (evfool) wrote :

Finally I have managed to check what's up with this branch :)

Thanks André Stösel (ivaldi) for the heads-up, the load error status wasn't cleared indeed in some cases, doing that in load committed didn't seem to be enough. I have moved the load error clearing to load started (a bit earlier in the process), to make sure the error status is clear when we start loading a page, and if we come back with an error, it will be set to error in the error callback, and with this change, it seems to work as expected. Could you please retest it, and update your review if it works?

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

My last test case works fine now, thanks for the patch.

There is just one minor issue left: it still sends a new DNS request for each status change if the DNS request fails because it does not exists.

But I guess that it could actually depend on the network connection which is used (VPN or intra- vs internet,..) -> so it should be fine.

Thanks again and sorry for the delay.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'midori/midori-app.c'
2--- midori/midori-app.c 2014-03-26 21:12:05 +0000
3+++ midori/midori-app.c 2014-04-14 07:13:35 +0000
4@@ -569,6 +569,24 @@
5 }
6
7 static void
8+midori_app_network_changed (GNetworkMonitor* monitor,
9+ gboolean available,
10+ MidoriApp* app)
11+{
12+ if (available)
13+ {
14+ MidoriBrowser *browser;
15+ KATZE_ARRAY_FOREACH_ITEM (browser, app->browsers) {
16+ GList* tabs = midori_browser_get_tabs (browser);
17+ for (; tabs != NULL; tabs = g_list_next (tabs))
18+ if (midori_tab_get_load_error (MIDORI_TAB (tabs->data)) == MIDORI_LOAD_ERROR_NETWORK)
19+ midori_view_reload (tabs->data, FALSE);
20+ g_list_free (tabs);
21+ }
22+ }
23+}
24+
25+static void
26 midori_app_create_instance (MidoriApp* app)
27 {
28 if (g_application_get_is_registered (G_APPLICATION (app)))
29@@ -602,6 +620,10 @@
30 "flags", G_APPLICATION_HANDLES_OPEN,
31 NULL);
32 g_signal_connect (app, "startup", G_CALLBACK (midori_app_startup_cb), NULL);
33+
34+ g_signal_connect (g_network_monitor_get_default (), "network-changed",
35+ G_CALLBACK (midori_app_network_changed), app);
36+
37 GError* error = NULL;
38 if (!g_application_register (G_APPLICATION (app), NULL, &error))
39 midori_error (error->message);
40
41=== modified file 'midori/midori-tab.vala'
42--- midori/midori-tab.vala 2014-03-26 21:12:05 +0000
43+++ midori/midori-tab.vala 2014-04-14 07:13:35 +0000
44@@ -33,6 +33,15 @@
45 PROVISIONAL /* A new URI was scheduled. */
46 }
47
48+ [CCode (cprefix = "MIDORI_LOAD_ERROR_")]
49+ public enum LoadError {
50+ NONE,
51+ DELAYED,
52+ SECURITY,
53+ CRASH,
54+ NETWORK
55+ }
56+
57 public class Tab : Gtk.VBox {
58 public Tab related { get; set construct; }
59 public WebKit.WebView web_view { get; private set; }
60@@ -56,6 +65,7 @@
61 /* Since: 0.1.2 */
62 public Security security { get; protected set; default = Security.NONE; }
63 public LoadStatus load_status { get; protected set; default = LoadStatus.FINISHED; }
64+ public LoadError load_error { get; protected set; default = LoadError.NONE; }
65 public string? statusbar_text { get; protected set; default = null; }
66 /* Since: 0.5.0 */
67
68
69=== modified file 'midori/midori-view.c'
70--- midori/midori-view.c 2014-04-06 16:31:06 +0000
71+++ midori/midori-view.c 2014-04-14 07:13:35 +0000
72@@ -683,6 +683,7 @@
73 {
74 midori_view_update_load_status (view, MIDORI_LOAD_PROVISIONAL);
75 midori_tab_set_progress (MIDORI_TAB (view), 0.0);
76+ midori_tab_set_load_error (MIDORI_TAB (view), MIDORI_LOAD_ERROR_NONE);
77 }
78
79 #ifdef HAVE_GCR
80@@ -765,6 +766,7 @@
81 midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_NONE);
82
83 view->find_links = -1;
84+
85 midori_view_update_load_status (view, MIDORI_LOAD_COMMITTED);
86
87 }
88@@ -1230,6 +1232,9 @@
89 result = midori_view_display_error (view, uri, "stock://dialog/network-error", title,
90 message, error->message, g_string_free (suggestions, FALSE),
91 _("Try Again"), web_frame);
92+
93+ midori_tab_set_load_error (MIDORI_TAB (view), MIDORI_LOAD_ERROR_NETWORK);
94+
95 g_free (message);
96 g_free (title);
97 return result;

Subscribers

People subscribed via source and target branches

to all changes: