<?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>172790</bug_id>
          
          <creation_ts>2017-05-31 17:45:18 -0700</creation_ts>
          <short_desc>Out of memory crash with MapBox-gl-js</short_desc>
          <delta_ts>2019-02-05 10:01:23 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebGL</component>
          <version>Safari 10</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=194268</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="zac spitzer">zac.spitzer</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>aaron</cc>
    
    <cc>ariel.hasidim</cc>
    
    <cc>bartzy</cc>
    
    <cc>beidson</cc>
    
    <cc>dino</cc>
    
    <cc>dylan</cc>
    
    <cc>joepeck</cc>
    
    <cc>juhani.lavonen</cc>
    
    <cc>justin_fan</cc>
    
    <cc>kling</cc>
    
    <cc>kristfal</cc>
    
    <cc>lee</cc>
    
    <cc>mad7</cc>
    
    <cc>matthew</cc>
    
    <cc>mike</cc>
    
    <cc>nial.david.giacomelli</cc>
    
    <cc>ol.stern</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zivilevy</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1314473</commentid>
    <comment_count>0</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2017-05-31 17:45:18 -0700</bug_when>
    <thetext>quoted from https://github.com/mapbox/mapbox-gl-js/issues/4695#issuecomment-305221298

I&apos;ve been digging deeper into this, and it seems like there is a memory leak in Safari on both mobile and desktop for mapbox-gl-js.

All mobile debugging have been done with the basic mapbox example https://www.mapbox.com/mapbox-gl-js/examples/ 
on an iPad Pro 6,3 (2 GB ram) running iOS 10.3.1. Desktop debugging was done on OS X Safari 10.1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314474</commentid>
    <comment_count>1</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2017-05-31 17:52:35 -0700</bug_when>
    <thetext>The error message is &quot;A problem occurred with this webpage so it was reloaded&quot; adding it so people can find this bug if looking for it</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1314509</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-05-31 19:54:27 -0700</bug_when>
    <thetext>&lt;rdar://problem/32503598&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1317081</commentid>
    <comment_count>3</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2017-06-08 15:10:13 -0700</bug_when>
    <thetext>There does look to be a WebGL-related leak here. We&apos;d have to check whether the page is entraining the data.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1340016</commentid>
    <comment_count>4</comment_count>
    <who name="Kristian F">kristfal</who>
    <bug_when>2017-08-18 01:50:29 -0700</bug_when>
    <thetext>@smfr, we&apos;re unable to isolate the issue to a single aspect of mapbox-gl-js. In addition, the same benchmarking tests causes another popular web-gl based map library, Tangram [https://github.com/tangrams/tangram] to crash on iOS devices as well. See https://github.com/mapbox/mapbox-gl-js/issues/4695#issuecomment-323087798 for details.

Let me know if you&apos;d like an isolated test case for this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1340401</commentid>
    <comment_count>5</comment_count>
    <who name="Brady Eidson">beidson</who>
    <bug_when>2017-08-19 10:09:33 -0700</bug_when>
    <thetext>(In reply to Kristian F from comment #4)
&gt; @smfr, we&apos;re unable to isolate the issue to a single aspect of mapbox-gl-js.
&gt; In addition, the same benchmarking tests causes another popular web-gl based
&gt; map library, Tangram [https://github.com/tangrams/tangram] to crash on iOS
&gt; devices as well. See
&gt; https://github.com/mapbox/mapbox-gl-js/issues/4695#issuecomment-323087798
&gt; for details.
&gt; 
&gt; Let me know if you&apos;d like an isolated test case for this issue.

The answer to “would you like an isolated reproducible test case?” is almost always *yes* :)

Thanks for your help tracking this down!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1341002</commentid>
    <comment_count>6</comment_count>
    <who name="Kristian F">kristfal</who>
    <bug_when>2017-08-22 01:53:26 -0700</bug_when>
    <thetext>@brady:

Np, let me know if there is anything else I can do to help resolve this!


You&apos;ll find a test example here: https://kristfal.github.io/mapbox-memory-test/

To reproduce a OOM crash:

1) Open the web page above on an iPad. They make the best test case due to larger screen size. I&apos;d recommend using an iPad A1475 or another model with 1 GB RAM for consistent and quick results
2) Press Start in the top left corner and the map will start animating through a predefined path and load map tiles as it animates
3) Memory usage will continue to increase until the browser tab eventually crashes and reloads with the &apos;A problem occurred..&apos; message

For iPads with 2GB memory, this happens when the com.apple.Webkit process has consumed between 750 and 850 MB of &quot;Real memory&quot;. For iPads with 1GB memory, this happens at around 400 - 500 MB.

Drop me a line if you have any questions or if you&apos;re unable to reproduce the crash.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1417104</commentid>
    <comment_count>7</comment_count>
    <who name="">juhani.lavonen</who>
    <bug_when>2018-04-23 23:38:15 -0700</bug_when>
    <thetext>Any updates on this? The memory leak and Safari crashing is release blocker for our customer and we would like to know what is the status of this bug? As stated earlier in this thread the crashing happens both in desktop and mobile Safari. We’ve also came across this memory leak when mapbox-gl-js map was removed and re-initialised. Currently we’re working on workarounds by removing and re-initialising the map from time to time but this causes map to blink and it is not a viable solution on a long run.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1417192</commentid>
    <comment_count>8</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-04-24 10:43:52 -0700</bug_when>
    <thetext>(In reply to Kristian F from comment #6)
&gt; @brady:
&gt; 
&gt; Np, let me know if there is anything else I can do to help resolve this!
&gt; 
&gt; 
&gt; You&apos;ll find a test example here:
&gt; https://kristfal.github.io/mapbox-memory-test/


This test doesn&apos;t work:
[Error] Failed to load resource: the server responded with a status of 401 (Unauthorized) (streets-v9, line 0)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1433706</commentid>
    <comment_count>9</comment_count>
    <who name="Aaron">aaron</who>
    <bug_when>2018-06-16 08:11:24 -0700</bug_when>
    <thetext>Any update on this? +1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1434229</commentid>
    <comment_count>10</comment_count>
    <who name="Justin Fan">justin_fan</who>
    <bug_when>2018-06-18 16:43:43 -0700</bug_when>
    <thetext>I&apos;m having trouble reproducing this with the map box example site on an iPad Pro 6,3 (as originally reported) running iOS 12. If you are still seeing this, please post your SW/HW configuration.

Kristian&apos;s test seems to be relying on an expired API key.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1440760</commentid>
    <comment_count>11</comment_count>
    <who name="zac spitzer">zac.spitzer</who>
    <bug_when>2018-07-09 23:49:28 -0700</bug_when>
    <thetext>Kristian has fixed the test
https://github.com/mapbox/mapbox-gl-js/issues/4695#issuecomment-399054123</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1459712</commentid>
    <comment_count>12</comment_count>
    <who name="olivier">ol.stern</who>
    <bug_when>2018-09-14 03:17:11 -0700</bug_when>
    <thetext>Hello,

any update on that?
Thanks</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1472989</commentid>
    <comment_count>13</comment_count>
    <who name="kleggerkoder">mike</who>
    <bug_when>2018-10-29 12:15:54 -0700</bug_when>
    <thetext>I can confirm this is still a problem on iOS 12 on iPad Mini 3</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1473345</commentid>
    <comment_count>14</comment_count>
    <who name="">nial.david.giacomelli</who>
    <bug_when>2018-10-30 11:50:48 -0700</bug_when>
    <thetext>I&apos;m also seeing a similar issue (documented here: https://github.com/mapbox/mapbox-gl-js/issues/7476) under macOS Mojave (10.14) and desktop Safari (Version 12.0 (14606.1.36.1.9).

To more easily reproduce the issue in my case I put together an example here: https://measuredweighed.github.io/mapboxgl-js-mem-usage/index.html. Simply click the &quot;Start&quot; button and you&apos;ll see Safari begin to report a significant increase of &quot;Page&quot; memory. This usage seems to climb, with only minor collections, until the &quot;Pause&quot; button is pressed. After waiting for a minute or so you should then see &quot;Page&quot; memory usage begin to drop somewhat. If the animation is allowed to continue, at least on my machine, the &quot;Page&quot; memory usage will simply continue to climb.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1474111</commentid>
    <comment_count>15</comment_count>
    <who name="Lee">lee</who>
    <bug_when>2018-11-01 08:50:15 -0700</bug_when>
    <thetext>Is there any update to this?  

We are also seeing this issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1475303</commentid>
    <comment_count>16</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2018-11-05 15:38:05 -0800</bug_when>
    <thetext>I definitely see the memory use increase on the tests.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1478347</commentid>
    <comment_count>17</comment_count>
    <who name="Lee">lee</who>
    <bug_when>2018-11-14 00:02:08 -0800</bug_when>
    <thetext>Hi Dean, 

That&apos;s great (kinda!) news!  Is there anything more you need from anyone here or is that case all you need now?

Thanks you!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1478504</commentid>
    <comment_count>18</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2018-11-14 10:20:34 -0800</bug_when>
    <thetext>No, thanks Lee. I&apos;ll ask if I need anything.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483496</commentid>
    <comment_count>19</comment_count>
    <who name="DT">dylan</who>
    <bug_when>2018-11-30 04:58:05 -0800</bug_when>
    <thetext>Hi Dean, 
we&apos;re also having the same issue. For us it really is a show stopper. Could you give a rough estimation for when / if the issue might be fixed. We will need to decide very soon either to keep or drop mapbox all together. 
Thx!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483523</commentid>
    <comment_count>20</comment_count>
    <who name="Ziv Levy">zivilevy</who>
    <bug_when>2018-11-30 07:29:31 -0800</bug_when>
    <thetext>Hi,

Any progress on this issue?
I experience this issue on mobile safar &amp; UIWebview (Using cordova).
Can&apos;t release the app to my customers.
Please advise on timeline for a fix or a workaround.

Best,
Ziv</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483605</commentid>
    <comment_count>21</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-11-30 11:14:18 -0800</bug_when>
    <thetext>I&apos;ve been able to run https://measuredweighed.github.io/mapboxgl-js-mem-usage/index.html for &gt; 5 minutes on iPhones ranging from iOS 10.3 to iOS 12, and have not seen any high memory crashes, suggesting that MapBox-gl may have fixed some issues?

DT and Ziv, can you please provide a URL for which you can reproduce this crash?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483668</commentid>
    <comment_count>22</comment_count>
    <who name="Marc A. Donis">mad7</who>
    <bug_when>2018-11-30 12:21:12 -0800</bug_when>
    <thetext>We are experiencing the same memory leak issue with Mapbox on iOS 10.  Not quite sure what to do about it.

Can you give any guidance as to when this bug will be fixed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483696</commentid>
    <comment_count>23</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-11-30 13:07:36 -0800</bug_when>
    <thetext>(In reply to Marc A. Donis from comment #22)
&gt; We are experiencing the same memory leak issue with Mapbox on iOS 10.  Not
&gt; quite sure what to do about it.

Do you have a reproducible case you can share?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483749</commentid>
    <comment_count>24</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2018-11-30 14:36:21 -0800</bug_when>
    <thetext>I&apos;ve also had https://measuredweighed.github.io/mapboxgl-js-mem-usage/index.html running for 10 minutes on various iPads without having the page restart due to lack of memory.

Marc, have you tried iOS 11?

DT, Ziv, what happens with that test for you?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483753</commentid>
    <comment_count>25</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2018-11-30 14:37:38 -0800</bug_when>
    <thetext>I notice the page is pulling the script from mapbox.com. Has mapbox made a change to either fix or work around this issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483763</commentid>
    <comment_count>26</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2018-11-30 14:41:56 -0800</bug_when>
    <thetext>Commented in the github issue - hopefully more people are watching that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1483956</commentid>
    <comment_count>27</comment_count>
    <who name="arielhasidim">ariel.hasidim</who>
    <bug_when>2018-12-01 01:19:26 -0800</bug_when>
    <thetext>Hello,
We also have the same deliberation about using cordova/mapbox in our product, joining the request for estimated timeline...

Thank&apos;s ahead :)
ariel hasidim</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1484316</commentid>
    <comment_count>28</comment_count>
    <who name="DT">dylan</who>
    <bug_when>2018-12-03 03:07:34 -0800</bug_when>
    <thetext>Hi Dean, 
we just realized that we&apos;re actually not seeing this issue at all. Our test case included loading and unloading mapbox maps repeatedly in a cordova application. The symptoms we saw were similar to what is being described here. But in our case the solution was as simple as calling map.remove() on destruction of the corresponding dom element. We also noticed that connecting safari dev tools to our cordova webview increased the memory pressure significantly and made the issue even more elusive. 
Sorry for the confusion. Maybe this insight helps somebody else as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1484338</commentid>
    <comment_count>29</comment_count>
    <who name="">matthew</who>
    <bug_when>2018-12-03 05:47:16 -0800</bug_when>
    <thetext>I am still able to reproduce this bug when extrusions (i.e. hillshade https://www.mapbox.com/mapbox-gl-js/example/hillshade/) are enabled after just a few minutes of usage, in particular intense zooming and jumping between locations.
I was never able to reproduce it via https://measuredweighed.github.io/mapboxgl-js-mem-usage/index.html.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1484540</commentid>
    <comment_count>30</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2018-12-03 14:56:21 -0800</bug_when>
    <thetext>@DT. I can reproduce this on the hillshade example. I note that after a lot of zooming and panning, the JS heap snapshot shows a lot of un-collected ArrayBuffers. The biggest handful are all 4MB, and don&apos;t increase in number.

However there are thousands of smaller buffers, from approx 200k to 0 that are never garbage collected. They are all marked as root objects, in that they are hanging off the window.

Using the heap profiler/snapshot, it looks like the buffers come from:

- GridIndex
- Placement.retainedQueryData
- Map.style
- image.data

and a few other places.

The same thing happens in Google Chrome - which suggests it&apos;s probably an issue in MapBox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1484545</commentid>
    <comment_count>31</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2018-12-03 15:01:40 -0800</bug_when>
    <thetext>Yeah, it seems window.map has references to all the ArrayBuffers that have been used.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1484549</commentid>
    <comment_count>32</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2018-12-03 15:04:59 -0800</bug_when>
    <thetext>The Google tools are a bit more helpful - suggesting window.map.style.sourceCaches is holding a lot of the buffers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1486730</commentid>
    <comment_count>33</comment_count>
    <who name="Dean Jackson">dino</who>
    <bug_when>2018-12-10 14:06:08 -0800</bug_when>
    <thetext>Closing this since it looks like it is a MapBox thing.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>