加桥/定位边界诊断日志,排查子游戏收不到 getlocationinfo
现象:大厅 H5 能正确拿到定位,子游戏拿不到。已静态排除「子游戏未注册 handler」与「回调错发给大厅」两个猜测(BridgeBus 是 per-WebView 实例、 handlers 是实例状态,反向 call 捕获各自的 bridge,物理上不可能串台; 下载真实子游戏 zip 比对后确认 H5 侧大厅/子游戏逻辑完全对称)。 为定位真正的失败层,在各组件边界加日志(纯诊断,不改任何行为): - BridgeBus 加 label(lobby / subGame)区分来源,记录 ← H5 调用、 → H5 反向 call、native handler 未注册、evaluateJavaScript 失败 - sendToJS 改为返回 'ok'/'no-bridge',H5 侧 bridge 未就绪导致的静默丢包 现在会打错误日志(原实现 `if (window.X)` 直接丢弃,完全不可见) - LocationService 记录 requestOnce 序号 / shared manager id / requestLocation 的 BOOL 返回值 / completionBlock 是否回来 / stop() 调用 —— 高德文档明确 requestLocation 返回 NO 时 completionBlock 永不调用, 当前代码忽略该返回值会让 continuation 永挂,H5 连 errorCode 12 都收不到 - H5ErrorRelay 补 console.warn 中继,让 WVJB「H5 侧无对应 handler」的 warn 能出现在 Xcode console 契约影响:无。仅新增日志与可选 label 参数,桥接接口名 / 字段名 / 数据结构 均未变动(docs/H5-Native-Contract.md §3.1[20]/ §3.2[6]不变)。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UMPCLfsuxvwgMotzsb67QH
This commit is contained in:
co-authored by
Claude Opus 5
parent
8a7d543cdc
commit
3f8b382ad3
@@ -48,6 +48,11 @@ public final class H5ErrorRelay: NSObject {
|
||||
case "console.error":
|
||||
let args = (dict["args"] as? [String]) ?? []
|
||||
print("[H5 console.error]", args.joined(separator: " "))
|
||||
case "console.warn":
|
||||
// 桥诊断需要:WebViewJavascriptBridge.js 在「Native 发来的 handlerName
|
||||
// H5 侧没注册」时走 console.warn,之前不上报导致这类丢包完全不可见。
|
||||
let args = (dict["args"] as? [String]) ?? []
|
||||
print("[H5 console.warn]", args.joined(separator: " "))
|
||||
case "onerror":
|
||||
let msg = (dict["msg"] as? String) ?? ""
|
||||
let src = (dict["src"] as? String) ?? ""
|
||||
@@ -80,6 +85,15 @@ public final class H5ErrorRelay: NSObject {
|
||||
} catch(e){}
|
||||
if (origErr) { origErr.apply(console, arguments); }
|
||||
};
|
||||
var origWarn = console.warn;
|
||||
console.warn = function(){
|
||||
try {
|
||||
var args = [];
|
||||
for (var i=0; i<arguments.length; i++) { args.push(String(arguments[i])); }
|
||||
send({ kind:'console.warn', args: args });
|
||||
} catch(e){}
|
||||
if (origWarn) { origWarn.apply(console, arguments); }
|
||||
};
|
||||
window.addEventListener('error', function(ev){
|
||||
send({
|
||||
kind:'onerror',
|
||||
|
||||
Reference in New Issue
Block a user