Skip to content

Commit 8d40782

Browse files
author
Hristo Hristov
authored
Style perf improvements (NativeScript#2342)
* Add css-perf app. * Style properties now check only properties that are set. Image utils module required on top (instead of in onMeasure) to improve performance. Remove try/catch block when Style applies native property. * fix tslint * Fix broken merge Update package.json version * Failed miserably - if the try/catch around applyProperty method is removed - TextField fails big time. TextField needs some good refactoring as well as calls to _updateTextDecoration & _updateTextTransform utils - setTextTransform & setTextDecoration should be split, typing support should be added.
1 parent 81dc102 commit 8d40782

File tree

21 files changed

+611
-99
lines changed

21 files changed

+611
-99
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="__PACKAGE__"
4+
android:versionCode="1"
5+
android:versionName="1.0">
6+
7+
<supports-screens
8+
android:smallScreens="true"
9+
android:normalScreens="true"
10+
android:largeScreens="true"
11+
android:xlargeScreens="true"/>
12+
13+
<uses-sdk
14+
android:minSdkVersion="17"
15+
android:targetSdkVersion="__APILEVEL__"/>
16+
17+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
18+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
19+
<uses-permission android:name="android.permission.INTERNET"/>
20+
21+
<application
22+
android:name="com.tns.NativeScriptApplication"
23+
android:allowBackup="true"
24+
android:icon="@drawable/icon"
25+
android:label="@string/app_name"
26+
android:theme="@style/AppTheme" >
27+
<activity
28+
android:name="com.tns.NativeScriptActivity"
29+
android:label="@string/title_activity_kimera"
30+
android:configChanges="keyboardHidden|orientation|screenSize">
31+
32+
<intent-filter>
33+
<action android:name="android.intent.action.MAIN" />
34+
35+
<category android:name="android.intent.category.LAUNCHER" />
36+
</intent-filter>
37+
</activity>
38+
<activity android:name="com.tns.ErrorReportActivity"/>
39+
</application>
40+
</manifest>

apps/App_Resources/iOS/Info.plist

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>${PRODUCT_NAME}</string>
9+
<key>CFBundleExecutable</key>
10+
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleIconFile</key>
12+
<string>icon.png</string>
13+
<key>CFBundleIcons</key>
14+
<dict>
15+
<key>CFBundlePrimaryIcon</key>
16+
<dict>
17+
<key>CFBundleIconFiles</key>
18+
<array>
19+
<string>icon-40</string>
20+
<string>icon-60</string>
21+
<string>icon-72</string>
22+
<string>icon-76</string>
23+
<string>Icon-Small</string>
24+
<string>Icon-Small-50</string>
25+
</array>
26+
<key>UIPrerenderedIcon</key>
27+
<false/>
28+
</dict>
29+
</dict>
30+
<key>CFBundleInfoDictionaryVersion</key>
31+
<string>6.0</string>
32+
<key>CFBundleName</key>
33+
<string>${PRODUCT_NAME}</string>
34+
<key>CFBundlePackageType</key>
35+
<string>APPL</string>
36+
<key>CFBundleShortVersionString</key>
37+
<string>1.0</string>
38+
<key>CFBundleSignature</key>
39+
<string>????</string>
40+
<key>CFBundleVersion</key>
41+
<string>1.0</string>
42+
<key>LSRequiresIPhoneOS</key>
43+
<true/>
44+
<key>UILaunchStoryboardName</key>
45+
<string>LaunchScreen</string>
46+
<key>UIRequiresFullScreen</key>
47+
<true/>
48+
<key>UIRequiredDeviceCapabilities</key>
49+
<array>
50+
<string>armv7</string>
51+
</array>
52+
<key>UISupportedInterfaceOrientations</key>
53+
<array>
54+
<string>UIInterfaceOrientationPortrait</string>
55+
<string>UIInterfaceOrientationLandscapeLeft</string>
56+
<string>UIInterfaceOrientationLandscapeRight</string>
57+
</array>
58+
<key>UISupportedInterfaceOrientations~ipad</key>
59+
<array>
60+
<string>UIInterfaceOrientationPortrait</string>
61+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
62+
<string>UIInterfaceOrientationLandscapeLeft</string>
63+
<string>UIInterfaceOrientationLandscapeRight</string>
64+
</array>
65+
</dict>
66+
</plist>

apps/css-perf-test/app.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import application = require("application");
2+
3+
global.time = function(): number {
4+
if (global.android) {
5+
return java.lang.System.nanoTime() / 1000000; // 1 ms = 1000000 ns
6+
}
7+
else {
8+
return CACurrentMediaTime() * 1000;
9+
}
10+
}
11+
12+
application.start({ moduleName: "css-perf-test/root" });

apps/css-perf-test/main-page.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.title {
2+
font-size: 20;
3+
margin: 3;
4+
}
5+
6+
.author {
7+
font-size: 14;
8+
horizontal-align: left;
9+
vertical-align: bottom;
10+
margin: 3;
11+
}
12+
13+
.comments {
14+
color: #10C2B0;
15+
font-size: 14;
16+
vertical-align: bottom;
17+
margin: 3;
18+
}
19+
20+
.thumbnail {
21+
width: 72;
22+
height: 72;
23+
margin: 3;
24+
vertical-align: top;
25+
}
26+
27+
TabView {
28+
background-color: white;
29+
}

apps/css-perf-test/main-page.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {EventData as ObservableEventData} from "data/observable";
2+
3+
export function navigatedTo(args: ObservableEventData) {
4+
setTimeout(() => {
5+
console.log(`Time: ${global.time() - global.startTime} ms`);
6+
});
7+
}

apps/css-perf-test/main-page.xml

Lines changed: 307 additions & 0 deletions
Large diffs are not rendered by default.

apps/css-perf-test/main-page2.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.title {
2+
font-size: 20;
3+
margin: 3;
4+
}
5+
6+
.author {
7+
font-size: 14;
8+
horizontal-align: left;
9+
vertical-align: bottom;
10+
margin: 3;
11+
}
12+
13+
.comments {
14+
color: #10C2B0;
15+
font-size: 14;
16+
vertical-align: bottom;
17+
margin: 3;
18+
}
19+
20+
.thumbnail {
21+
width: 72;
22+
height: 72;
23+
margin: 3;
24+
vertical-align: top;
25+
}
26+
27+
TabView {
28+
background-color: white;
29+
}

apps/css-perf-test/res/logo.png

26.2 KB
Loading

apps/css-perf-test/root.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {Page} from "ui/page";
2+
3+
export function onTap(args: any) {
4+
global.startTime = global.time();
5+
let page = <Page>args.object.page;
6+
page.frame.navigate("css-perf-test/main-page");
7+
}

apps/css-perf-test/root.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
2+
<Button text="Start test" tap="onTap" />
3+
</Page>

0 commit comments

Comments
 (0)