
查看应用的Web渲染线程,发现耗时集中在H:EvaluateScript和H:v8.callFunction,网页加载时JS编译与执行耗时较多,与网页有关。

import { webview } from '@kit.ArkWeb';
@Entry
@Component
struct PrivacyPage {
webviewController: WebviewController = new webview.WebviewController();
@State isLoading: boolean = true;
build() {
Stack() {
Web({
src: $r('app.string.test_url'), // 测试时请替换成实际地址
controller: this.webviewController,
}).onPageEnd(() => {
this.isLoading = false;
})
.fileAccess(false)
.geolocationAccess(false)
if(this.isLoading) {
LoadingProgress()
.width(100)
.height(100)
}
}
.height('100%')
.width('100%')
}
}