gpt4 book ai didi

javascript - 带有 processMessage 失败错误的应用程序无限循环

转载 作者:可可西里 更新时间:2023-11-01 01:32:56 25 4
gpt4 key购买 nike

我的 Cordova 应用程序未在浏览器和移动设备中运行,它显示错误

processMessage failed

截图:

enter image description here

然后进入无限循环并卡住设备任何解决方案?

这个问题已经在这里问了Cordova not running normally但没有答案,所以我不得不再次询问。

最佳答案

遇到同样的问题(使用 Chrome 和 phonegap 桌面模拟器。我看到的是这个。

Cordova.js 中似乎存在无法检查空消息的错误。当应用程序发出警报时:gap_init:2差距:[0,“StatusBar”,“_ready”,“StatusBar1593157203”]差距:[0,“应用程序”,“显示”,“App1593157204”]差距:[0,"file",“requestAllPaths”,“File1593157205”]差距:[0,“NetworkStatus”,“getConnectionInfo”,“NetworkStatus1593157206”]差距:[0,“设备”,“getDeviceInfo”,“Device1593157207”]

您只需点击“确定”,而不是清除该对话框的内容,它会继续导致无限循环。我不知道这些消息的重要性是的,因为我对 Cordova 还很陌生,但这太糟糕了,而且已经偏离了最小惊喜原则!

因此您可以清除消息,或修改卡在循环中的 cordova.js 代码。您也可以关闭同样有效的警报。

函数 processMessage()(见下文)不测试空字符串,它本身可能没问题,但它是从一个 while 循环调用的,该循环只检查“*”是否要弹出.

while (messagesFromNative.length) {
var msg = popMessageFromQueue();
// The Java side can send a * message to indicate that it
// still has messages waiting to be retrieved.
if (msg == '*' && messagesFromNative.length === 0) {
setTimeout(pollOnce, 0);
return;
}
processMessage(msg);
}

// Processes a single message, as encoded by NativeToJsMessageQueue.java.
function processMessage(message) {
try {
var firstChar = message.charAt(0);
if (firstChar == 'J') {
eval(message.slice(1));
} else if (firstChar == 'S' || firstChar == 'F') {
var success = firstChar == 'S';
var keepCallback = message.charAt(1) == '1';
var spaceIdx = message.indexOf(' ', 2);
var status = +message.slice(2, spaceIdx);
var nextSpaceIdx = message.indexOf(' ', spaceIdx + 1);
var callbackId = message.slice(spaceIdx + 1, nextSpaceIdx);
var payloadKind = message.charAt(nextSpaceIdx + 1);
var payload;
if (payloadKind == 's') {
payload = message.slice(nextSpaceIdx + 2);
} else if (payloadKind == 't') {
payload = true;
} else if (payloadKind == 'f') {
payload = false;
} else if (payloadKind == 'N') {
payload = null;
} else if (payloadKind == 'n') {
payload = +message.slice(nextSpaceIdx + 2);
} else if (payloadKind == 'A') {
var data = message.slice(nextSpaceIdx + 2);
var bytes = window.atob(data);
var arraybuffer = new Uint8Array(bytes.length);
for (var i = 0; i < bytes.length; i++) {
arraybuffer[i] = bytes.charCodeAt(i);
}
payload = arraybuffer.buffer;
} else if (payloadKind == 'S') {
payload = window.atob(message.slice(nextSpaceIdx + 2));
} else {
payload = JSON.parse(message.slice(nextSpaceIdx + 1));
}
cordova.callbackFromNative(callbackId, success, status, [payload], keepCallback);
} else {
console.log("processMessage failed: invalid message: " + JSON.stringify(message));
}
} catch (e) {
console.log("processMessage failed: Error: " + e);
console.log("processMessage failed: Stack: " + e.stack);
console.log("processMessage failed: Message: " + message);
}
}

关于javascript - 带有 processMessage 失败错误的应用程序无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28539479/

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