<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>264879</bug_id>
          
          <creation_ts>2023-11-15 08:40:29 -0800</creation_ts>
          <short_desc>[GTK][WPE] Limit memory used by target strings serialized in WebKitWebViewSessionState</short_desc>
          <delta_ts>2025-03-18 02:41:13 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>Other</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=268410</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=289945</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Guilaume Ayoub">guillaume.webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aperez</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>kdwkleung</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>nekohayo</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1992798</commentid>
    <comment_count>0</comment_count>
    <who name="Guilaume Ayoub">guillaume.webkit</who>
    <bug_when>2023-11-15 08:40:29 -0800</bug_when>
    <thetext>More information about this bug can be found here: https://gitlab.gnome.org/GNOME/epiphany/-/issues/1610</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1994433</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-11-22 12:14:32 -0800</bug_when>
    <thetext>I&apos;m not sure we&apos;re even gaining much anything from all this memory use. The point of serializing the state of the web view is to be able to restore it instantly without having to load everything again. And for Apple ports this actually happens, but for GTK/WPE we do a new load anyway to ensure we don&apos;t display stale content. (E.g. it would be really confusing to open your browser to this Bugzilla page and not see new comments posted since the last time you manually reloaded the page, which could be days or weeks ago.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1994486</commentid>
    <comment_count>2</comment_count>
    <who name="Kdwk">kdwkleung</who>
    <bug_when>2023-11-22 21:14:17 -0800</bug_when>
    <thetext>I think the ideal experience would be to restore the old page first, then do a fresh load in the background, and switch to that when the new one has been fully loaded.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1996214</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-12-01 07:28:08 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #1)
&gt; I&apos;m not sure we&apos;re even gaining much anything from all this memory use. The
&gt; point of serializing the state of the web view is to be able to restore it
&gt; instantly without having to load everything again. And for Apple ports this
&gt; actually happens, but for GTK/WPE we do a new load anyway to ensure we don&apos;t
&gt; display stale content. (E.g. it would be really confusing to open your
&gt; browser to this Bugzilla page and not see new comments posted since the last
&gt; time you manually reloaded the page, which could be days or weeks ago.)

I did some archaeology and found bug #115600 was where we agreed to disable this. I wonder if we should revisit this choice. Anyway, that won&apos;t fix this bug; it would only make the excessive memory use worth something. Right now I suspect it&apos;s all wasted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1996215</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2023-12-01 07:28:37 -0800</bug_when>
    <thetext>Sorry, bug #115600 was where this API was introduced. I meant to link to bug #153230.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011784</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-02-08 09:25:08 -0800</bug_when>
    <thetext>Apple recommends we limit the size of the session state in our platform-specific code, bug #268410. I think this is acceptable; it should be OK to drop the session state if it gets too large.

That said, ideally we should not attempt to save the entire page cache into session state. It should be sufficient to save only the current page. Serializing everything in the back/forward list just to make the back button work faster after the browser is closed and reopened is overkill.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2011788</commentid>
    <comment_count>6</comment_count>
    <who name="Guilaume Ayoub">guillaume.webkit</who>
    <bug_when>2024-02-08 09:30:39 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #5)
&gt; Apple recommends we limit the size of the session state in our
&gt; platform-specific code, bug #268410. I think this is acceptable; it should
&gt; be OK to drop the session state if it gets too large.

It would definitely work for me, as my current &quot;solution&quot; is a sed command removing the history attribute from session_state.xml when it gets too large.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2103753</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2025-03-17 07:35:40 -0700</bug_when>
    <thetext>*** Bug 289898 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2103844</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-03-17 15:13:44 -0700</bug_when>
    <thetext>Committed 292282@main (99f7a1b31bae): &lt;https://commits.webkit.org/292282@main&gt;

Reviewed commits have been landed. Closing PR #42568 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2103845</commentid>
    <comment_count>9</comment_count>
    <who name="Guilaume Ayoub">guillaume.webkit</who>
    <bug_when>2025-03-17 15:19:12 -0700</bug_when>
    <thetext>Thanks a lot! 💘</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2103959</commentid>
    <comment_count>10</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2025-03-18 02:41:13 -0700</bug_when>
    <thetext>@Guillaume: No problem at all!

We may be able to make the session state somewhat smaller by limiting the total size stored, see bug #289945 for that.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>