<?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>241012</bug_id>
          
          <creation_ts>2022-05-27 07:21:28 -0700</creation_ts>
          <short_desc>WPE aborts in RaspberryPi 4 with: &quot;The renderer process ran out of memory&quot;</short_desc>
          <delta_ts>2022-09-16 04:44:25 -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>New Bugs</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>245222</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=245222</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="Manuel A. Fernandez Montecelo">mafm</reporter>
          <assigned_to name="Miguel Gomez">magomez</assigned_to>
          <cc>guijemont</cc>
    
    <cc>magomez</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>olivier.blin</cc>
    
    <cc>pnormand</cc>
    
    <cc>psaavedra</cc>
    
    <cc>zdobersek</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1872320</commentid>
    <comment_count>0</comment_count>
    <who name="Manuel A. Fernandez Montecelo">mafm</who>
    <bug_when>2022-05-27 07:21:28 -0700</bug_when>
    <thetext>About 30 seconds after starting the browser, even with simple internal pages like &quot;webkit://gpu&quot;, the renderer aborts.

The error reported within the browser window and the terminal is:

  11(cog:717): Cog-Core-WARNING **: 13:54:54.429: &lt;webkit://gpu/&gt; Out of memory!: The renderer process ran out of memory. You may try reloading the page to restart it.

This happens on 32-bit builds for RaspberryPi4, Zan Dobersek traced it to:
https://github.com/WebKit/WebKit/blob/main/Source/WTF/wtf/MemoryPressureHandler.cpp#L98

... using sizes larger than size_t in 32-bits, and overflowing and getting to size=0 when adding 7+1GB when tabCount=1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1875200</commentid>
    <comment_count>1</comment_count>
    <who name="Guillaume Emont">guijemont</who>
    <bug_when>2022-06-10 01:55:24 -0700</bug_when>
    <thetext>I can reproduce it on a raspberry pi 3 (running in 32-bits).
This log line might be more telling:
  Unable to shrink memory footprint of process (80 MB) below the kill thresold (0 MB). Killed

I can work around it with a recent version of cog (tried with 0.13.3) by passing it the option --web-kill-threshold=600 or whatever value makes sense with the amount of RAM you have.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898412</commentid>
    <comment_count>2</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2022-09-14 00:50:05 -0700</bug_when>
    <thetext>Confirmed on another embedded device, tracked this down yesterday and finished this morning with the same conclusion. In MemoryPressureHandler thresholdForMemoryKillOfInactiveProcess() returns 0 (where it is supposed to compute &apos;constant + N * something&apos;, so should always be &gt; 0, unless things e.g. overflow, as Zan pointed out).

Anyhow, Miguel recently added fine-grained configuration possibilities for the MemoryPressureHandler behavior. So the choice for the embedder is to either specify the optional MemoryPressure related settings (shrinkOrDie() will then use the killFractionThreshold from the &apos;Configuration&apos; rather than some hard-coded formulas, given the embedder a real choice to influence the memory pressure reactions).

This is opt-in at present and thus the default behavior in main is broken.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898665</commentid>
    <comment_count>3</comment_count>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2022-09-15 04:06:52 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/4375</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898671</commentid>
    <comment_count>4</comment_count>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2022-09-15 04:16:37 -0700</bug_when>
    <thetext>When I implemented the configuration support for the MemoryPressureHandler, active processes were never killed unless the application set a killThreshold through the configuration.

After that Apple added a default threshold to kill processes, which is the value that&apos;s overflowing on 32 bits systems. But we shouldn&apos;t be using Apple&apos;s default values as we don&apos;t kill any process unless the application has explicitly set a killThreshold value through the MemoryPressureHandler configuration.

The PR I&apos;ve sent stops using Apple&apos;s thresholds for killing processes and uses only the values set to the MemoryPressureHandler&apos;s configuration to decide whether a process must be killed or not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898919</commentid>
    <comment_count>5</comment_count>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2022-09-16 00:32:51 -0700</bug_when>
    <thetext>The overflow problem has been already fixed by https://commits.webkit.org/254533@main so this can be closed as a duplicate of that one.

What I was trying to do here was, instead of just fixing the overflow, was matching the behavior with what&apos;s explained in the MemoryPressureHandler documentation, which is that no process is killed if there&apos;s no killThreshold defined.

Then, as Michael mentioned in the PR, it&apos;s true that in many cases we would like to keep a reasonable threshold to kill the process even if the app is not setting a value through the MemoryPressureHandler configuration.

So I&apos;m just going to close this as a duplicate of https://bugs.webkit.org/show_bug.cgi?id=245222 and close the PR. Eventually I&apos;ll change the MemoryPressureHandler documentation to state that if the app doesn&apos;t set a killThreshold, we will use a default value.

*** This bug has been marked as a duplicate of bug 245222 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898922</commentid>
    <comment_count>6</comment_count>
    <who name="Olivier Blin">olivier.blin</who>
    <bug_when>2022-09-16 00:43:28 -0700</bug_when>
    <thetext>Thanks for the update Miguel, sorry I do not notice that you were already working on this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898948</commentid>
    <comment_count>7</comment_count>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2022-09-16 04:44:25 -0700</bug_when>
    <thetext>(In reply to Olivier Blin from comment #6)
&gt; Thanks for the update Miguel, sorry I do not notice that you were already
&gt; working on this.

No problem Olivier! thanks for the fix! ;)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>