I can also see the bug on macOS with Safari 12.0.<p>I find it quite worrying that devs already wrote a lib to fix the issue but didn't fill a bug report to Apple and shared it on SO. Anyway, a trendy HN post might be enough to get the attention of some Apple devs and I've pinged a dev just in case: <a href="https://twitter.com/ArmandGrillet/status/1042339847384518656" rel="nofollow">https://twitter.com/ArmandGrillet/status/1042339847384518656</a>
It appears this was already reported and fixed in WebKit - <a href="https://bugs.webkit.org/show_bug.cgi?id=188794" rel="nofollow">https://bugs.webkit.org/show_bug.cgi?id=188794</a> but not specifically for the Safari browser.
This bug is very much like the most common mistake I see on Common Lisp stack overflow where one tries to mutate constant (quoted) data.<p>However JavaScript has no similar notion of constant data but implementations try to infer it as an optimisation. In this case that inference was wrong.<p>I think the memory structure looks something like:<p><pre><code> arr -> box1 -> 1,2,3,4
</code></pre>
Reversing:<p><pre><code> arr -> box1 -> 4,3,2,1
</code></pre>
But the data occupying the same region of memory before and after the sort. So then when the page is refreshed the JavaScript doesn’t change and the literal data must be included in the “parsed/compiled” form that is reused and so it is initialised as<p><pre><code> arr -> box2 -> 4,3,2,1
</code></pre>
The correct behaviour should be as follows:<p><pre><code> 1. arr -> box1 -> loc1: 1,2,3,4
2. Reverse
3. arr -> box1 -> loc2: 4,3,2,1
4. Refresh
5. arr -> box2 -> loc1: 1,2,3,4
</code></pre>
The “box” corresponds to the JavaScript object for the array (so mutating the array data can change the box, the data it points at, but not just the reference “arr” as the object might be pointed to from elsewhere). And this box has another pointer to the data for the array (and presumably some bit flag to say whether that is copy-on-write or not). This allows for more efficient array functions when the data doesn’t actually change
The weirdest thing about this is the fact that the bug occurs after a page reload. Does safari cache jit code and the javascript heap/objects between pageloads?
I think Apple has to consider separating Safari (and other bundled apps) from the iOS release so that users can update a quick fix through the App Store without waiting for a new iOS update.<p>There was a serious WebAssembly regression in iOS 11.2 that makes wasm effectively useless [1]. Devs had to disable wasm and wait for <i>months</i> until iOS 11.3 is released.<p>Apple never releases a iOS hot fix just for a single Safari bug. Then why Apple don't let users to update Safari separately?<p>[1]: <a href="https://bugs.webkit.org/show_bug.cgi?id=181781" rel="nofollow">https://bugs.webkit.org/show_bug.cgi?id=181781</a>
Bug does not trigger on "Safari Technology Preview Release 65 (Safari 12.1, WebKit 13607.1.5.2)" on macOS 10.13.6. Fixed already, or not yet introduced?
Woah. I think I ran into this last night after updating to Safari 12 on macOS. I was typing my message into messenger.com (facebook messenger), and all of my typing was reversed. I even took a photo of it
I'm not seeing Safari 12 in the App Store (macOS 10.13.6). I wonder if they pulled the update because of this? I have Safari 11 still but my colleague got Safari 12 through the App Store.
Isn't this part of the faster loading that some Web browsers do? Essentially the idea is that the browser muddies the idea of a closed page in favour of being able to restore it faster.
>I wrote a lib to fix the bug. <a href="https://www.npmjs.com/package/array-reverse-polyfill" rel="nofollow">https://www.npmjs.com/package/array-reverse-polyfill</a><p>everyday we stray further from god
Now they will release iOS 13 for this :)<p>P.S. <a href="https://www.youtube.com/watch?v=uG8bNDw6Ftc" rel="nofollow">https://www.youtube.com/watch?v=uG8bNDw6Ftc</a>
Ironically, I got an ad banner for Apple at the top of this page. Saying "Engineer in Europe. Innovate at Apple."<p>However, this bug sounds pretty serious! :-S