Skip to content

Commit 5e767b9

Browse files
authored
Merge pull request #1743 from NativeScript/feature/v8-10.3.22-perf
feature/v8 10.3.22 perf
2 parents c2c8aa8 + cf757a5 commit 5e767b9

File tree

575 files changed

+61037
-224949
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

575 files changed

+61037
-224949
lines changed

Diff for: build.dev.sh

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
# smaller version of build.sh that sets the commit hash to the current git commit hash and uses the package.json version
3+
4+
echo "Ensure adb is in PATH"
5+
export PATH="$ANDROID_HOME/platform-tools:$PATH"
6+
adb version
7+
8+
echo "Update submodule"
9+
git submodule update --init
10+
11+
echo "Cleanup old build and test artefacts"
12+
rm -rf consoleLog.txt
13+
rm -rf test-app/dist/*.xml
14+
15+
./gradlew cleanRuntime
16+
17+
./gradlew -PgitCommitVersion=$(git rev-parse HEAD)
18+
cp dist/nativescript-android-*.tgz dist/nativescript-android.tgz
19+

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@nativescript/android",
33
"description": "NativeScript for Android using v8",
4-
"version": "8.4.0",
4+
"version": "8.5.0",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/NativeScript/android.git"

Diff for: test-app/app/src/main/assets/app/mainpage.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,6 @@ require("./tests/kotlin/extensions/testExtensionFunctionsSupport");
6666
require("./tests/kotlin/enums/testEnumsSupport");
6767
require("./tests/kotlin/access/testInternalLanguageFeaturesSupport");
6868
require("./tests/testPackagePrivate");
69-
require("./tests/kotlin/properties/testPropertiesSupport.js")
69+
require("./tests/kotlin/properties/testPropertiesSupport.js");
70+
require('./tests/testNativeTimers');
71+
require("./tests/console/logTests.js");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
describe("Test JSONObject conversions", () => {
2+
it("console.log with number param should not crash", () => {
3+
console.log(123);
4+
});
5+
6+
it("console.log with string param should not crash", () => {
7+
console.log("123");
8+
});
9+
10+
it("console.log with object param should not crash", () => {
11+
console.log({ num: 123 });
12+
});
13+
14+
it("console.log with function param should not crash", () => {
15+
console.log(function() {});
16+
});
17+
18+
it("console.log with arrow function param should not crash", () => {
19+
console.log(() => {});
20+
});
21+
22+
it("console.log with primitive array param should not crash", () => {
23+
console.log([1, 2, 3]);
24+
});
25+
26+
it("console.log with object array param should not crash", () => {
27+
console.log([{
28+
num: 123
29+
}]);
30+
});
31+
});

Diff for: test-app/app/src/main/assets/app/tests/exceptionHandlingTests.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ describe("Tests exception handling ", function () {
322322

323323
// run this test only for API level bigger than 25 as we have handling there
324324
if(android.os.Build.VERSION.SDK_INT > 25 && android.os.Build.CPU_ABI != "x86" && android.os.Build.CPU_ABI != "x86_64") {
325-
it("Should handle SIGABRT and throw a NativeScript exception when incorrectly calling JNI methods", function () {
325+
xit("Should handle SIGABRT and throw a NativeScript exception when incorrectly calling JNI methods", function () {
326326
let myClassInstance = new com.tns.tests.MyTestBaseClass3();
327327
// public void callMeWithAString(java.lang.String[] stringArr, Runnable arbitraryInterface)
328328
try {
+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
describe('native timer', () => {
2+
3+
/** @type {global.setTimeout} */
4+
let setTimeout = global.__ns__setTimeout;
5+
/** @type {global.setInterval} */
6+
let setInterval = global.__ns__setInterval; /** @type global.setTimeout */
7+
/** @type {global.clearTimeout} */
8+
let clearTimeout = global.__ns__clearTimeout;
9+
/** @type {global.clearInterval} */
10+
let clearInterval = global.__ns__clearInterval;
11+
12+
it('exists', () => {
13+
expect(setTimeout).toBeDefined();
14+
expect(setInterval).toBeDefined();
15+
expect(clearTimeout).toBeDefined();
16+
expect(clearInterval).toBeDefined();
17+
});
18+
19+
it('triggers timeout', (done) => {
20+
const now = Date.now();
21+
setTimeout(() => {
22+
expect(Date.now() - now).not.toBeLessThan(100);
23+
done();
24+
}, 100);
25+
});
26+
27+
it('triggers timeout', (done) => {
28+
const now = Date.now();
29+
setTimeout(() => {
30+
expect(Date.now() - now).not.toBeLessThan(100);
31+
done();
32+
}, 100);
33+
});
34+
35+
it('triggers interval', (done) => {
36+
let calls = 0;
37+
const itv = setInterval(() => {
38+
calls++;
39+
}, 100);
40+
setTimeout(() => {
41+
clearInterval(itv);
42+
expect(calls).toBe(10);
43+
done();
44+
}, 1000);
45+
});
46+
47+
it('cancels timeout', (done) => {
48+
let triggered = false;
49+
const now = Date.now();
50+
const timeout = setTimeout(() => {
51+
triggered = true;
52+
}, 100);
53+
clearTimeout(timeout);
54+
setTimeout(() => {
55+
expect(triggered).toBe(false);
56+
done();
57+
}, 200);
58+
});
59+
60+
it('cancels interval', (done) => {
61+
let triggered = false;
62+
const now = Date.now();
63+
const timeout = setInterval(() => {
64+
triggered = true;
65+
}, 100);
66+
clearInterval(timeout);
67+
setTimeout(() => {
68+
expect(triggered).toBe(false);
69+
done();
70+
}, 200);
71+
});
72+
73+
it('cancels interval inside function', (done) => {
74+
let calls = 0;
75+
const itv = setInterval(() => {
76+
calls++;
77+
clearInterval(itv);
78+
}, 10);
79+
setTimeout(() => {
80+
expect(calls).toBe(1);
81+
done();
82+
}, 100);
83+
});
84+
85+
it('preserves order', (done) => {
86+
let calls = 0;
87+
setTimeout(() => {
88+
expect(calls).toBe(0);
89+
calls++;
90+
});
91+
setTimeout(() => {
92+
expect(calls).toBe(1);
93+
calls++;
94+
done();
95+
});
96+
});
97+
it('frees up resources after complete', (done) => {
98+
let timeout = 0;
99+
let interval = 0;
100+
let weakRef;
101+
{
102+
let obj = {
103+
value: 0
104+
};
105+
weakRef = new WeakRef(obj);
106+
timeout = setTimeout(() => {
107+
obj.value++;
108+
}, 100);
109+
interval = setInterval(() => {
110+
obj.value++;
111+
}, 50);
112+
}
113+
setTimeout(() => {
114+
// use !! here because if you pass weakRef.get() it creates a strong reference (side effect of expect)
115+
expect(!!weakRef.get()).toBe(true);
116+
clearInterval(interval);
117+
clearTimeout(timeout);
118+
// use another timeout as native weakrefs can't be gced until we leave the isolate after being used once
119+
setTimeout(() => {
120+
gc();
121+
expect(!!weakRef.get()).toBe(false);
122+
done();
123+
})
124+
}, 200);
125+
})
126+
});

0 commit comments

Comments
 (0)