| 17 | [https://bugs.webkit.org/show_bug.cgi?id=188728 Bug 188728] is a good example; in this case, after running IndexedDB tests, we notice that the Document for the main page is never released. A bit of investigation shows that this can be replicated in MiniBrowser by making a small test change to navigate as soon as the test is complete (see the [https://bugs.webkit.org/show_bug.cgi?id=188728#c7 small test patch]). Reproducing in MiniBrowser just makes it a little easier to debug. |
| 18 | |
| 19 | Here's how we confirm that we are actually seeing a real problem: |
| 20 | 1. We start the test server so that the web-platform-test actually works: {{{./Tools/Scripts/run-webkit-httpd}}} |
| 21 | 2. Now run MiniBrowser and load the test, using the localhost url [http://localhost:8800/IndexedDB/value.htm] |
| 22 | 3. The test automatically navigates to about:blank now, but the previous page may still be in the page cache (and referenced by other cached things), so we need to trigger a low memory warning, which will clear those caches. On Apple platforms, we can do that via the {{{notifyutil}}} utility: {{{notifyutil -p org.WebKit.lowMemory}}}. That clears caches, and triggers a GC. |
| 23 | 4. Now we can see what Documents are still live, again using notifyutil: {{{notifyutil -p com.apple.WebKit.showAllDocuments}}}. This will dump to the system log (and your Terminal or Xcode, wherever you ran MiniBrowser from). You'll see something like: |
| 24 | {{{ |
| 25 | 1 live pages: |
| 26 | Page 0x1168fe000 with main document 0x1161bf000 file:///Volumes/Data/Development/apple/webkit/testcontent/simple/A.html |
| 27 | 2 live documents: |
| 28 | Document 0x11615e000 http://localhost:8800/IndexedDB/value.htm |
| 29 | Document 0x1161bf000 about:blank |
| 30 | }}} |
| 31 | So that shows us that value.htm is still around, which is bad. |
| 32 | |
| 33 | 5. Now we can dump the GC heap, again with notifyutil: {{{notifyutil -p com.apple.WebKit.showAllDocuments}}}. This will log something like: {{{Dumped GC heap to /var/folders/bh/34x83y_n4mn5n_nv0v_rdmh80000gn/T/org.webkit.MiniBrowser/GCHeapOayHEu}}}. |
| 34 | That's your JSON output, so copy the file somewhere to keep it: |
| 35 | {{{mv Dumped GC heap to /var/folders/bh/34x83y_n4mn5n_nv0v_rdmh80000gn/T/org.webkit.MiniBrowser/GCHeapOayHEu ~/Desktop/values-heap.json}}} |
| 36 | |
| 37 | 6. The heap viewer is located in {{{Tools/GCHeapInspector}}}. I usually fire up a local server to use it: |
| 38 | {{{ |
| 39 | cd Tools/GCHeapInspector |
| 40 | python -m SimpleHTTServer 8999 |
| 41 | }}} |
| 42 | (port 8999 to avoid conflicting with the webkit test localhost ports) |
| 43 | 7. Now in the browser navigate to [http://0.0.0.0:8999/gc-heap-inspector.html]. You'll see the GC heap inspector banner. Now drag your {{{~/Desktop/values-heap.json}}} file onto the badge in the top right. |