Details
-
Bug
-
Resolution: Incomplete
-
P1: Critical
-
6.4.2, 6.5.1
-
None
Description
I discovered that my application behaves unexpectedly when running in WebKit-based browsers. After some investigation, I found out that there is some issue when a variable is defined in a Javascript block. For example, the following snippet produces the output:
var a = -1;
console.log(a);
5.562684646268e-309
What is interesting is that I was able to reproduce this issue only for integers from the [-127,-1] interval.
However, when a variable is defined using the Number function call (Math.floor work too, for example) like so:
var a = Number(-1); console.log(a);
... the output seems to be correct:
-1
... so I assume that there is not a problem with printing the output, but rather memory allocation.
Maybe another example that works correctly:
var a = 0 - 1;
Furthermore, I also discovered, that the issue does not occur from the start, but rather that the engine breaks after some (short) time. Again, I tried to eliminate the possibility that my code corrupts the engine/stack/etc., so I created a minimal reproducible example:
// unittest.qml import QtQuick Rectangle { width: 100 height: 100 Component.onCompleted: { for (var i = 0; i < 1000000; i++) { var c = -1 === Number(-1) var d = -1 === -1 if (c !== d) { var a = -1 console.log("error", i, a) return } } console.log("ok") } }
// main.cpp // ... includes ... int main(int argc, char **argv) { auto& app = *(new QApplication(argc, argv)); QQuickView *view = new QQuickView; view->setSource(QUrl::fromLocalFile("unittest.qml")); view->show(); return 0; }
The following is printed to log:
error 268680 5.562684646268e-309
I am using Qt 6.4.2 with Emscripten 3.1.31-2.
I was able to reproduce this in the following device-browser environments:
- iPhone 13 Mini with iOS 16.5: Safari, Chrome, Firefox
- iPad Pro 2020 with iPadOS 16.6: all browsers
- M1 Mac Mini with Ventura 13.4.1: Safari, (but Chrome/Firefox works ok)
- M2 Macbook Pro with Ventura 13.4.1: Safari, (but Chrome/Firefox works ok)
Attachments
For Gerrit Dashboard: QTBUG-116138 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
498383,4 | Workaround undefined webkit behavior | dev | qt/qtdeclarative | Status: DEFERRED | -1 | 0 |