gpt4 book ai didi

javascript - WebView 导致应用程序崩溃

转载 作者:行者123 更新时间:2023-11-30 02:45:49 26 4
gpt4 key购买 nike

您好,我有一个非常基本的 Titanium 应用程序。有 3 个 Web View 。当一开始就有 wifi 时,所有三个 WebView 都可以正常加载。我检查了我的代码,其中只有在有互联网连接时才添加 webview。如果没有,我会添加一个说明连接到互联网的标签和一个刷新按钮。当我单击刷新按钮时,Web View 的添加使应用程序崩溃。代码适用于 iOS,不适用于 Android。使用 SDK 3.2.3。代码如下:

refresh.addEventListener("click", function (e){
if(Ti.Network.online){
console.log(" here 1 -----------");
Navbar.remove(refresh);
console.log(" here 2 -----------");
self.remove(NoInternet_view);
console.log(" here 3 -----------");
self.add(shopWebView);
console.log(" here 4 -----------");
}
else{
alert("An internet connection is required");
}
});

日志打印输出“here 3 ----------”然后崩溃。

相关日志:

F/libc    (12588): Fatal signal 11 (SIGSEGV) at 0x0000000c (code=1), thread 12612 (KrollRuntimeThr)
[INFO][DEBUG ( 1764)] *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
[INFO][DEBUG ( 1764)] Build fingerprint: 'samsung/lt01wifixx/lt01wifi:4.2.2/JDQ39/T310XXUAMF1:user/release-keys'
[INFO][DEBUG ( 1764)] Revision: '6'
[INFO][DEBUG ( 1764)] pid: 12588, tid: 12612, name: KrollRuntimeThr >>> com.girt.cuddles <<<
[INFO][DEBUG ( 1764)] signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0000000c
[INFO][DEBUG ( 1764)] r0 00000000 r1 5e93c4e8 r2 000000aa r3 00000001
[INFO][DEBUG ( 1764)] r4 00000000 r5 5a386ec8 r6 5e49f9bc r7 00000000
[INFO][DEBUG ( 1764)] r8 5e49f88f r9 5e49f870 sl 5e49f9bc fp 5eb506a5
[INFO][DEBUG ( 1764)] ip 5ea062f8 sp 5e49f818 lr 5e518473 pc 5e518284 cpsr 40000030
[INFO][DEBUG ( 1764)] d0 0000000000000000 d1 4018000000000000
[INFO][DEBUG ( 1764)] d2 0000000000000000 d3 000f4240003d0900
[INFO][DEBUG ( 1764)] d4 0000000000000001 d5 3ff0000000000000
[INFO][DEBUG ( 1764)] d6 0000860100000000 d7 0000860100000000
[INFO][DEBUG ( 1764)] d8 0000000000000000 d9 0000000000000000
[INFO][DEBUG ( 1764)] d10 0000000000000000 d11 0000000000000000
[INFO][DEBUG ( 1764)] d12 0000000000000000 d13 0000000000000000
[INFO][DEBUG ( 1764)] d14 0000000000000000 d15 0000000000000000
[INFO][DEBUG ( 1764)] d16 0000000000000001 d17 0000000000000000
[INFO][DEBUG ( 1764)] d18 0000000000004001 d19 0000000000000000
[INFO][DEBUG ( 1764)] d20 3fc554e7eb0eb47c d21 3e66376972bea4d0
[INFO][DEBUG ( 1764)] d22 3f4de16b9c24a98f d23 3fb0f4a31edab38b
[INFO][DEBUG ( 1764)] d24 3fede16b9c24a98f d25 3fe55559ee5e69f9
[INFO][DEBUG ( 1764)] d26 0000000000000000 d27 0000000000000000
[INFO][DEBUG ( 1764)] d28 0000000000000000 d29 0000000000000000
[INFO][DEBUG ( 1764)] d30 0000000000000000 d31 0000000000000000
[INFO][DEBUG ( 1764)] scr 60000013
[INFO][DEBUG ( 1764)]
[INFO][DEBUG ( 1764)] backtrace:
[INFO][DEBUG ( 1764)] #00 pc 00078284 /data/app-lib/com.girt.cuddles-1/libkroll-v8.so (titanium::EventEmitter::~EventEmitter()+71)
[INFO][DEBUG ( 1764)] #01 pc 0007846f /data/app-lib/com.girt.cuddles-1/libkroll-v8.so (titanium::JavaObject::getJavaObject()+58)
[INFO][DEBUG ( 1764)] #02 pc 0007e157 /data/app-lib/com.girt.cuddles-1/libkroll-v8.so (titanium::TypeConverter::jsValueToJavaObject(_JNIEnv*, v8::Local<v8::Value>, bool*)+302)
[INFO][DEBUG ( 1764)] #03 pc 0009a2f9 /data/app-lib/com.girt.cuddles-1/libkroll-v8.so (titanium::TiViewProxy::add(v8::Arguments const&)+332)
[INFO][DEBUG ( 1764)] #04 pc 00171034 /data/app-lib/com.girt.cuddles-1/libkroll-v8.so
[INFO][DEBUG ( 1764)] #05 pc 00067c00 <unknown>
[INFO][DEBUG ( 1764)]
[INFO][DEBUG ( 1764)] stack:
[INFO][DEBUG ( 1764)] 5e49f7d8 40043d5c
[INFO][DEBUG ( 1764)] 5e49f7f4 4094f6e4 /system/lib/libdvm.so
[INFO][DEBUG ( 1764)] 5e49f7f8 00000000
[INFO][DEBUG ( 1764)] 5e49f7fc 59f04dc8
[INFO][DEBUG ( 1764)] 5e49f800 409d1c98 /system/lib/libdvm.so
[INFO][DEBUG ( 1764)] 5e49f804 57225378 /dev/ashmem/dalvik-LinearAlloc (deleted)
[INFO][DEBUG ( 1764)] #00 5e49f818 5ea06218 /data/app-lib/com.girt.cuddles-1/libkroll-v8.so
[INFO][DEBUG ( 1764)] ........ ........
[INFO][BootReceiver( 2125)] Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
[INFO][dumpstate(13169)] begin
[WARN][ContextImpl( 2125)] Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1346 com.android.server.analytics.data.collection.application.CrashAnrDetector.broadcastEvent:291 com.android.server.analytics.data.collection.application.CrashAnrDetector.processDropBoxEntry:254 com.android.server.analytics.data.collection.application.CrashAnrDetector.access$100:60 com.android.server.analytics.data.collection.application.CrashAnrDetector$1.onReceive:102
[INFO][Monitor ( 2125)] SIOP:: Current AP = 360, CP = 0
[INFO][dumpstate(13169)] done
[INFO][SurfaceFlinger( 1771)] id=71 Removed UiActivity (2/4)
[INFO][ActivityManager( 2125)] Process com.girt.cuddles (pid 12588) (adj 0) has died.
[WARN][InputDispatcher( 2125)] channel ~ Consumer closed input channel or an error occurred. events=0x9
[ERROR][InputDispatcher( 2125)] channel ~ Channel is unrecoverably broken and will be disposed!

编辑:与 map 页面关联的代码:

var removeRefresh = function removeRefresh() {
if(Ti.Network.getOnline()) {
console.log("issue 1-------");
self.remove(NoInternet_view);
console.log("issue 2-------");
self.add(map1);
console.log("issue 3-------");
Navbar.remove(refresh);
console.log("issue 4-------");
}
else alert("An internet connection is required");
};
refresh.addEventListener("click", removeRefresh);

最佳答案

您正在销毁匿名处理程序中的刷新 (Ti.UI.Button)。

你可以试试这段代码:

var removeRefresh = function removeRefresh() {
if(Ti.Network.getOnline()) {
Ti.API.info(" Checkpoint 1 -----------");
self.remove(NoInternet_view);
Ti.API.info(" Checkpoint 2 -----------");
self.add(shopWebView);
Ti.API.info(" Checkpoint 3 -----------");
Navbar.remove(refresh);
Ti.API.info(" Checkpoint 4 -----------");
}
else alert("An internet connection is required");
};
refresh.addEventListener("click", removeRefresh);

您必须确保现有的 NoInternet_view 和 shopWebView。

Titanium Studio 控制台将显示四个消息 (Ti.API.info)

关于javascript - WebView 导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25063206/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com