After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 119432 - Session saving should save window/tab history and re-instate it on session restore
Session saving should save window/tab history and re-instate it on session re...
Status: RESOLVED FIXED
Product: epiphany
Classification: Core
Component: History
3.18.x (obsolete)
Other Linux
: Normal enhancement
: ---
Assigned To: Epiphany Maintainers
Epiphany Maintainers
: 132406 155820 158435 311528 413935 546076 706747 (view as bug list)
Depends on:
Blocks: 755388 760782
 
 
Reported: 2003-08-08 13:54 UTC by lwillis
Modified: 2016-01-20 19:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the beginnings of an implementation (19.02 KB, patch)
2003-10-06 15:13 UTC, Christian Persch
none Details | Review
another half-finished patch (25.97 KB, patch)
2004-11-11 00:26 UTC, Christian Persch
none Details | Review
embed: Remove unused EphyEmbedShell::prepare-close signal (3.21 KB, patch)
2016-01-14 17:11 UTC, Carlos Garcia Campos
committed Details | Review
ephy-session: always set dont_save to false in ephy_session_close() (1.09 KB, patch)
2016-01-14 17:12 UTC, Carlos Garcia Campos
committed Details | Review
ephy-session: Never save the session if the policy is set to never (992 bytes, patch)
2016-01-14 17:12 UTC, Carlos Garcia Campos
committed Details | Review
ephy-session: Remove filename parameter from ephy_session_save() (6.88 KB, patch)
2016-01-14 17:13 UTC, Carlos Garcia Campos
committed Details | Review
ephy-session: do not start the save task immediately (4.13 KB, patch)
2016-01-14 17:13 UTC, Carlos Garcia Campos
committed Details | Review
ephy-session: Save the session also when active tab changes (1.32 KB, patch)
2016-01-14 17:14 UTC, Carlos Garcia Campos
committed Details | Review
ephy-session: save and restore web view session state (8.65 KB, patch)
2016-01-14 17:14 UTC, Carlos Garcia Campos
committed Details | Review

Description lwillis 2003-08-08 13:54:55 UTC
I should be able to do the following:

- Open epiphany
- Go to www.gnome.org
- Click on software map
- Log out of GNOME 
- Log into GNOME
- See the software map page [This does work]
- Hit the browser back button and get to www.gnome.org

The last step doesn't work, the tab has no history associated with it.
Comment 1 Dave Bordoley [Not Reading Bug Mail] 2003-08-08 15:54:27 UTC
yeah this is a good idea.
Comment 2 Christian Persch 2003-10-06 15:13:54 UTC
Created attachment 20512 [details] [review]
the beginnings of an implementation
Comment 3 Christian Persch 2003-10-06 15:15:04 UTC
My patch has some infrastructure work to get more info about the
session history items, and saves the info in the session file. Now if
I could find a way to re-populate the session history with the entries
on loading the session...
Comment 4 Marco Pesenti Gritti 2003-10-06 18:09:45 UTC
What's the prob exactly ? My impression is that we are going to get
problems with embed initialization here ...
Comment 5 alexander.winston 2004-01-24 05:13:19 UTC
Adding the PATCH keyword.
Comment 6 Christian Persch 2004-01-24 11:14:29 UTC
Removing PATCH keyword, since the patch is not complete and even
doesn't apply cleanly anymore.
Comment 7 Christian Persch 2004-04-08 22:05:16 UTC
Comment on attachment 20512 [details] [review]
the beginnings of an implementation

Marking attachments in open bugs.
Comment 8 Reinout van Schouwen 2004-06-20 20:57:39 UTC
Would this RFE also apply to 'crashed' sessions, so that Back and Forward would
retain the history per page?
Comment 9 Christian Persch 2004-06-20 21:58:10 UTC
Yes, since the session saving code is the same for crashed sessions and
session-managed sessions.
Comment 10 Christian Persch 2004-08-23 15:07:12 UTC
-> History
Comment 11 Christian Persch 2004-10-13 10:53:32 UTC
Mass reassigning of Epiphany bugs to epiphany-maint@b.g.o
Comment 12 Christian Persch 2004-10-19 13:56:10 UTC
*** Bug 155820 has been marked as a duplicate of this bug. ***
Comment 13 Christian Persch 2004-11-11 00:26:15 UTC
Created attachment 33661 [details] [review]
another half-finished patch

This is a half-finished, non-compiling patch.

Since I could not find ANY way to create a new instance of nsISHEntry, I had to
abandon it. It seems there is NO way to implement this currently :(
Comment 14 Christian Persch 2004-11-16 12:41:50 UTC
*** Bug 158435 has been marked as a duplicate of this bug. ***
Comment 15 Christian Persch 2005-08-21 17:21:34 UTC
*** Bug 311528 has been marked as a duplicate of this bug. ***
Comment 16 Reinout van Schouwen 2007-03-02 23:07:33 UTC
*** Bug 413935 has been marked as a duplicate of this bug. ***
Comment 17 Reinout van Schouwen 2008-08-04 21:56:46 UTC
*** Bug 546076 has been marked as a duplicate of this bug. ***
Comment 18 Reinout van Schouwen 2008-08-04 21:57:24 UTC
Any chance of this feature being implemented with the webkit backend?
Comment 19 Andres Gomez 2015-10-05 13:48:14 UTC
Sounds like bug 706747 is a DUPLICATED of this bug ?
Comment 20 Michael Catanzaro 2015-10-05 14:29:39 UTC
*** Bug 706747 has been marked as a duplicate of this bug. ***
Comment 21 Carlos Garcia Campos 2016-01-14 17:11:26 UTC
Created attachment 319027 [details] [review]
embed: Remove unused EphyEmbedShell::prepare-close signal
Comment 22 Carlos Garcia Campos 2016-01-14 17:12:04 UTC
Created attachment 319028 [details] [review]
ephy-session: always set dont_save to false in ephy_session_close()
Comment 23 Carlos Garcia Campos 2016-01-14 17:12:37 UTC
Created attachment 319029 [details] [review]
ephy-session: Never save the session if the policy is set to never
Comment 24 Carlos Garcia Campos 2016-01-14 17:13:09 UTC
Created attachment 319030 [details] [review]
ephy-session: Remove filename parameter from ephy_session_save()
Comment 25 Carlos Garcia Campos 2016-01-14 17:13:39 UTC
Created attachment 319031 [details] [review]
ephy-session: do not start the save task immediately
Comment 26 Carlos Garcia Campos 2016-01-14 17:14:14 UTC
Created attachment 319032 [details] [review]
ephy-session: Save the session also when active tab changes
Comment 27 Carlos Garcia Campos 2016-01-14 17:14:40 UTC
Created attachment 319033 [details] [review]
ephy-session: save and restore web view session state
Comment 28 Carlos Garcia Campos 2016-01-14 17:20:01 UTC
*** Bug 132406 has been marked as a duplicate of this bug. ***
Comment 29 Carlos Garcia Campos 2016-01-14 17:22:50 UTC
We still need to save/restore the session on recently closed tabs too, but I'll use a different bug for that.
Comment 30 Michael Catanzaro 2016-01-14 17:46:51 UTC
Review of attachment 319027 [details] [review]:

OK
Comment 31 Michael Catanzaro 2016-01-14 17:53:48 UTC
Review of attachment 319028 [details] [review]:

It's a bit confusing that ephy_session_close just causes further session changes to be discarded... I also don't understand why this behavior was previously specific to EPHY_PREFS_RESTORE_SESSION_POLICY_ALWAYS.
Comment 32 Michael Catanzaro 2016-01-14 17:55:27 UTC
Review of attachment 319029 [details] [review]:

OK
Comment 33 Michael Catanzaro 2016-01-14 17:57:57 UTC
Review of attachment 319030 [details] [review]:

::: src/ephy-session.c
@@ +827,3 @@
+		GFile *session_file;
+
+		session_file = get_session_file (SESSION_STATE);

Can't you also get rid of this parameter to get_session_file(), and then simplify the implementation of get_session_file()?
Comment 34 Michael Catanzaro 2016-01-14 18:02:48 UTC
Review of attachment 319031 [details] [review]:

::: src/ephy-session.c
@@ +546,3 @@
+		 */
+		g_source_remove (priv->save_source_id);
+		ephy_session_save_idle_cb (session);

I think it's worthwhile to defensively set priv->save_source_id = 0 here, even though it is not currently necessary.
Comment 35 Michael Catanzaro 2016-01-14 18:09:44 UTC
Review of attachment 319032 [details] [review]:

::: src/ephy-session.c
@@ +436,3 @@
 	g_signal_connect (notebook, "page-reordered",
 			  G_CALLBACK (notebook_page_reordered_cb), session);
+	g_signal_connect_after (notebook, "switch-page",

I might have used g_signal_connect_data() here, with G_CONNECT_AFTER | G_CONNECT_SWAPPED, to call ephy_session_save() directly and avoid notebook_switch_page_cb(). But this is fine too.
Comment 36 Michael Catanzaro 2016-01-14 18:19:07 UTC
Review of attachment 319033 [details] [review]:

::: embed/ephy-embed.c
@@ +649,3 @@
+  item = webkit_back_forward_list_get_current_item (webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (web_view)));
+  if (item)
+    webkit_web_view_go_to_back_forward_list_item (WEBKIT_WEB_VIEW (web_view), item);

Why do you need to check the back/forward list? Shouldn't the final item in the back/forward list always match delayed_request?

@@ +886,3 @@
  * @embed: a #EphyEmbed
  * @request: a #WebKitNetworkRequest
+ * @state: a #WebKitWebViewSessionState

(nullable)

::: src/ephy-session.c
@@ +599,3 @@
 	session_tab->title = g_strdup (ephy_embed_get_title (embed));
 	session_tab->loading = ephy_web_view_is_loading (web_view) && !ephy_embed_has_load_pending (embed);
+	session_tab->state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW (web_view));//webkit_web_view_session_state_serialize(state);

Remove the leftover comment.

@@ +1176,3 @@
+			if (item)
+			{
+				webkit_web_view_go_to_back_forward_list_item (WEBKIT_WEB_VIEW (web_view), item);

Same question here.
Comment 37 Carlos Garcia Campos 2016-01-15 07:44:14 UTC
(In reply to Michael Catanzaro from comment #33)
> Review of attachment 319030 [details] [review] [review]:
> 
> ::: src/ephy-session.c
> @@ +827,3 @@
> +		GFile *session_file;
> +
> +		session_file = get_session_file (SESSION_STATE);
> 
> Can't you also get rid of this parameter to get_session_file(), and then
> simplify the implementation of get_session_file()?

No, because we support loading the session from any file path, and this method is also used in that case in the load methods.
Comment 38 Carlos Garcia Campos 2016-01-15 07:47:56 UTC
(In reply to Michael Catanzaro from comment #31)
> Review of attachment 319028 [details] [review] [review]:
> 
> It's a bit confusing that ephy_session_close just causes further session
> changes to be discarded... I also don't understand why this behavior was
> previously specific to EPHY_PREFS_RESTORE_SESSION_POLICY_ALWAYS.

Yes, we could probably use a better name. The thing is that the session watches the state of the windows and tabs. When closing the application, tabs are removed and other stuff might change, but we don't want to save that changes or we will always end up with an empty session. This also probably made more sense if save was actually public and could be called from other methods, but it's not the case so we could probably disconnect all the signals in close to ensure we don't save the session after close. But anyway, current solution is simple enough and it just works.
Comment 39 Carlos Garcia Campos 2016-01-15 07:49:30 UTC
(In reply to Michael Catanzaro from comment #34)
> Review of attachment 319031 [details] [review] [review]:
> 
> ::: src/ephy-session.c
> @@ +546,3 @@
> +		 */
> +		g_source_remove (priv->save_source_id);
> +		ephy_session_save_idle_cb (session);
> 
> I think it's worthwhile to defensively set priv->save_source_id = 0 here,
> even though it is not currently necessary.

It's the first thing ephy_session_save_idle_cb does and it will always do that, but I don't mind making it explicit here for clarity.
Comment 40 Carlos Garcia Campos 2016-01-15 07:54:21 UTC
(In reply to Michael Catanzaro from comment #36)
> Review of attachment 319033 [details] [review] [review]:
> 
> ::: embed/ephy-embed.c
> @@ +649,3 @@
> +  item = webkit_back_forward_list_get_current_item
> (webkit_web_view_get_back_forward_list (WEBKIT_WEB_VIEW (web_view)));
> +  if (item)
> +    webkit_web_view_go_to_back_forward_list_item (WEBKIT_WEB_VIEW
> (web_view), item);
> 
> Why do you need to check the back/forward list? Shouldn't the final item in
> the back/forward list always match delayed_request?

No, if delayed_state is NULL (that will happen for sure the first time your run this code because your current state file doesn't have state data, and it could happen if for some reason something fails when serializing state), then the bf list will be empty. It can also happen if delayed_state is not NULL but webkit_web_view_restore_session_state fails, for example if serialized data is invalid or corrupt. So, if we have an item in the bf list it means the session was correctly restored.

> @@ +886,3 @@
>   * @embed: a #EphyEmbed
>   * @request: a #WebKitNetworkRequest
> + * @state: a #WebKitWebViewSessionState
> 
> (nullable)

Ok.

> ::: src/ephy-session.c
> @@ +599,3 @@
>  	session_tab->title = g_strdup (ephy_embed_get_title (embed));
>  	session_tab->loading = ephy_web_view_is_loading (web_view) &&
> !ephy_embed_has_load_pending (embed);
> +	session_tab->state = webkit_web_view_get_session_state (WEBKIT_WEB_VIEW
> (web_view));//webkit_web_view_session_state_serialize(state);
> 
> Remove the leftover comment.

Oops

> @@ +1176,3 @@
> +			if (item)
> +			{
> +				webkit_web_view_go_to_back_forward_list_item (WEBKIT_WEB_VIEW
> (web_view), item);
> 
> Same question here.

Same answer.
Comment 41 Michael Catanzaro 2016-01-15 16:53:43 UTC
(In reply to Carlos Garcia Campos from comment #40)
> No, if delayed_state is NULL (that will happen for sure the first time your
> run this code because your current state file doesn't have state data, and
> it could happen if for some reason something fails when serializing state),
> then the bf list will be empty.

Sure.

> It can also happen if delayed_state is not
> NULL but webkit_web_view_restore_session_state fails, for example if
> serialized data is invalid or corrupt.

Sure.

> So, if we have an item in the bf list
> it means the session was correctly restored.

Sure, but so what? I understand that this code:

+			item = webkit_back_forward_list_get_current_item (bf_list);
+			if (item)
+			{
+				webkit_web_view_go_to_back_forward_list_item (WEBKIT_WEB_VIEW (web_view), item);
+			}
+			else
+			{
+				ephy_web_view_load_url (web_view, url);
+			}

works and is valid, but why is it better to check the b/f list than to simply call ephy_web_view_load_url (web_view, url). The last item in the WebKit session's b/f list should be the same as the one saved in the Epiphany session XML, so I don't see much value in checking the b/f list at all. (This is a fairly minor point.)
Comment 42 Carlos Garcia Campos 2016-01-16 08:20:21 UTC
(In reply to Michael Catanzaro from comment #41)
> (In reply to Carlos Garcia Campos from comment #40)
> > No, if delayed_state is NULL (that will happen for sure the first time your
> > run this code because your current state file doesn't have state data, and
> > it could happen if for some reason something fails when serializing state),
> > then the bf list will be empty.
> 
> Sure.
> 
> > It can also happen if delayed_state is not
> > NULL but webkit_web_view_restore_session_state fails, for example if
> > serialized data is invalid or corrupt.
> 
> Sure.
> 
> > So, if we have an item in the bf list
> > it means the session was correctly restored.
> 
> Sure, but so what? I understand that this code:
> 
> +			item = webkit_back_forward_list_get_current_item (bf_list);
> +			if (item)
> +			{
> +				webkit_web_view_go_to_back_forward_list_item (WEBKIT_WEB_VIEW
> (web_view), item);
> +			}
> +			else
> +			{
> +				ephy_web_view_load_url (web_view, url);
> +			}
> 
> works and is valid, but why is it better to check the b/f list than to
> simply call ephy_web_view_load_url (web_view, url). The last item in the
> WebKit session's b/f list should be the same as the one saved in the
> Epiphany session XML, so I don't see much value in checking the b/f list at
> all. (This is a fairly minor point.)

When you restore the session, the bf list current item is the one you want to load, but there's nothing loaded in the webview, so if you do load_url, a new entry will be added to the bf list, while we want to keep the current one.
Comment 43 Carlos Garcia Campos 2016-01-16 08:44:54 UTC
I agree that maybe it doesn't look obvious that you need to do a bf navigation, and I've noticed today that it causes problems, for example today after restoring my session, some of the tabs were loaded with old content (for example this one had a new comment that I didn't see until I manually reloaded the page). I'm not sure if that's caused by the bf navigation, I assumed the page cache was empty. This is what WebKit does internally when navigate is true in WebPageProxy::restoreFromSessionState() after restoring the session.

// FIXME: Navigating should be separate from state restoration.
if (navigate) {
    m_sessionRestorationRenderTreeSize = sessionState.renderTreeSize;
    if (!m_sessionRestorationRenderTreeSize)
        m_hitRenderTreeSizeThreshold = true; // If we didn't get data on renderTreeSize, just don't fire the milestone.
    if (!sessionState.provisionalURL.isNull())
        return loadRequest(sessionState.provisionalURL);

    if (hasBackForwardList) {
        // FIXME: Do we have to null check the back forward list item here?
    if (WebBackForwardListItem* item = m_backForwardList->currentItem())
            return goToBackForwardItem(item);
    }
}

So, to make it easier, we could add a specific load method. I didn't add navigate parameter to our API because of the FIXME above. So, maybe, webkit_web_view_load_from_session_state (WebKitWebView *, WebKitWebViewSessionState *)

That would allow us to use any other internal information of the SessionState without exposing it to the user.
Comment 44 Michael Catanzaro 2016-01-16 15:10:29 UTC
(In reply to Carlos Garcia Campos from comment #42)
> When you restore the session, the bf list current item is the one you want
> to load, but there's nothing loaded in the webview, so if you do load_url, a
> new entry will be added to the bf list, while we want to keep the current
> one.

OK, would be good to add a comment to warn about this.

(In reply to Carlos Garcia Campos from comment #43)
> I agree that maybe it doesn't look obvious that you need to do a bf
> navigation, and I've noticed today that it causes problems, for example
> today after restoring my session, some of the tabs were loaded with old
> content (for example this one had a new comment that I didn't see until I
> manually reloaded the page).

Hm, that is a big problem. It seems our session state mechanism is TOO good.

> So, to make it easier, we could add a specific load method. I didn't add
> navigate parameter to our API because of the FIXME above. So, maybe,
> webkit_web_view_load_from_session_state (WebKitWebView *,
> WebKitWebViewSessionState *)
> 
> That would allow us to use any other internal information of the
> SessionState without exposing it to the user.

Sounds good.
Comment 45 Carlos Garcia Campos 2016-01-16 16:31:48 UTC
(In reply to Michael Catanzaro from comment #44)
> (In reply to Carlos Garcia Campos from comment #42)
> > When you restore the session, the bf list current item is the one you want
> > to load, but there's nothing loaded in the webview, so if you do load_url, a
> > new entry will be added to the bf list, while we want to keep the current
> > one.
> 
> OK, would be good to add a comment to warn about this.
> 
> (In reply to Carlos Garcia Campos from comment #43)
> > I agree that maybe it doesn't look obvious that you need to do a bf
> > navigation, and I've noticed today that it causes problems, for example
> > today after restoring my session, some of the tabs were loaded with old
> > content (for example this one had a new comment that I didn't see until I
> > manually reloaded the page).
> 
> Hm, that is a big problem. It seems our session state mechanism is TOO good.

I'll check it in detail, it could be that the page was loaded from the disk cache, bypassing the revalidation because of the bf navigation.

> > So, to make it easier, we could add a specific load method. I didn't add
> > navigate parameter to our API because of the FIXME above. So, maybe,
> > webkit_web_view_load_from_session_state (WebKitWebView *,
> > WebKitWebViewSessionState *)
> > 
> > That would allow us to use any other internal information of the
> > SessionState without exposing it to the user.
> 
> Sounds good.
Comment 46 Carlos Garcia Campos 2016-01-19 11:09:02 UTC
(In reply to Carlos Garcia Campos from comment #45)
> (In reply to Michael Catanzaro from comment #44)
> > (In reply to Carlos Garcia Campos from comment #42)
> > > When you restore the session, the bf list current item is the one you want
> > > to load, but there's nothing loaded in the webview, so if you do load_url, a
> > > new entry will be added to the bf list, while we want to keep the current
> > > one.
> > 
> > OK, would be good to add a comment to warn about this.
> > 
> > (In reply to Carlos Garcia Campos from comment #43)
> > > I agree that maybe it doesn't look obvious that you need to do a bf
> > > navigation, and I've noticed today that it causes problems, for example
> > > today after restoring my session, some of the tabs were loaded with old
> > > content (for example this one had a new comment that I didn't see until I
> > > manually reloaded the page).
> > 
> > Hm, that is a big problem. It seems our session state mechanism is TOO good.
> 
> I'll check it in detail, it could be that the page was loaded from the disk
> cache, bypassing the revalidation because of the bf navigation.
> 

This is exactly what happens, see https://bugs.webkit.org/show_bug.cgi?id=142831 and https://bugs.webkit.org/show_bug.cgi?id=153230
Comment 47 Carlos Garcia Campos 2016-01-20 09:53:55 UTC
All patches pushed to git master, depending on 2.11.4, since it contains important fixes in session serializing/deserializing code to prevent data corruption.
Comment 48 Michael Catanzaro 2016-01-20 19:24:30 UTC
I am concerned about the cache revalidation issue we have introduced with this patchset. I trust you will try to fix that before 3.20.