Seen in Safari 15.1, 15.2 (macOS) and Epiphany 41.3 (Linux) According to the ECMAScript specification (https://tc39.es/ecma262/multipage/managing-memory.html#sec-weakrefderef), a WeakRef's deref method should either return the referenced object or `undefined`. This behaves as expected in Chrome, Firefox and Edge, but it seems that in WebKit browsers this method may return `null` instead. I've confirmed this behavior using the following in the dev tools console: ``` a = new WeakRef(new ArrayBuffer(10000000)) // wait a while to allow GC to clean up the ArrayBuffer a.deref() ``` I'm not sure if Webkit browsers have a way to force garbage collection, but waiting a while or using other tabs seems to work for triggering this issue most of the time. Firefox allows forcing GC on about:memory, Chrome and Edge provide a button for this on the Memory tab of their dev tools. Expected behavior: a.deref() returns undefined (happens in Chrome, Firefox and Edge) Actual behavior: a.deref() returns null in Safari and Epiphany
<rdar://problem/88513359>
Created attachment 450955 [details] Patch
Created attachment 450956 [details] Patch
Comment on attachment 450956 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=450956&action=review > Source/JavaScriptCore/ChangeLog:8 > + WeakRef#deref should return undefined when a wrapped object is collected. nit: a spec link perhaps? https://tc39.es/ecma262/#sec-weakrefderef
Thanks Sam and Alexey!
Comment on attachment 450956 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=450956&action=review >> Source/JavaScriptCore/ChangeLog:8 >> + WeakRef#deref should return undefined when a wrapped object is collected. > > nit: a spec link perhaps? https://tc39.es/ecma262/#sec-weakrefderef Nice, done.
Committed r289152 (246848@trunk): <https://commits.webkit.org/246848@trunk>