| 14 | |
| 15 | = How do I debug document abandonment? = |
| 16 | |
| 17 | Let's take an example [https://bugs.webkit.org/show_bug.cgi?id=188722]. We run tests, checking for abandonment: |
| 18 | |
| 19 | {{{ |
| 20 | run-webkit-tests fast/forms/ --check-for-abandoned-documents |
| 21 | }}} |
| 22 | |
| 23 | The results say that {{{fast/forms/textarea-paste-newline.html}}} was abandoned. Now you have to figure out why this Document object is not going away. |
| 24 | |
| 25 | A bit of testing in MiniBrowser can be useful, and if you're lucky, the abandonment will reproduce there. To test this, do these steps: |
| 26 | 1. Run MiniBrowser |
| 27 | 2. Load a simple HTML file (not the test!) |
| 28 | 3. Load the test file |
| 29 | 4. Go back to the simple HTML file |
| 30 | 5. Simulate a memory warning (on macOS, you can do this by running {{{notifyutil -p "org.WebKit.lowMemory"}}} in the Terminal). |
| 31 | 6. Now dump the list of live documents: {{{notifyutil -p "com.apple.WebKit.showAllDocuments"}}}. This will show something like: |
| 32 | {{{ |
| 33 | 2 live documents: |
| 34 | Document 0x630002400 (refCount 5, referencingNodeCount 1) file:///Volumes/Data/webkit/LayoutTests/fast/forms/textarea-paste-newline.html |
| 35 | Document 0x630024400 (refCount 2, referencingNodeCount 4) file:///Volumes/Data/simple.html |
| 36 | }}} |
| 37 | 7. That confirms that after a memory warning (which clears caches and does a GC) that the document is still alive. So something is holding a reference to it. |