[Bug]: Plugin call after navigation can be answered before reply proxy is updated
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- android, java
- 领域
- mobile-dev
调研方向
从 MessageHandler.java 开始,检查导航或重新加载期间回复代理更新与消息发布的顺序。在 Android 上通过快速读取 Preferences 重现该问题,然后验证新页面发起的插件调用使用更新后的代理并得到解析,而不是被静默丢弃。
由索引模型根据 Issue 内容生成。
描述
Capacitor Version
@capacitor/cli: 8.4.0
@capacitor/core: 8.4.0
@capacitor/android: 8.4.0
Other API Details
npm: 11.0.0
node: 22.13.0
Platforms Affected
- iOS
- Android
- Web
Current Behavior
After a reload or navigation, a fast plugin call (e.g. a Preferences read, which is how the bug appeared for us) can potentially never resolve as it uses the previous proxy instead of the updated one. The cause are these lines in MessageHandler.java:
if (isMainFrame) {
postMessage(message.getData());
javaScriptReplyProxy = replyProxy;
}
In case of a fast plugin call, sendResponseMessage() is reached before the proxy is updated, and therefore still uses the previous proxy and is silently dropped. Later calls work, and there's also no issue upon first page load as, at this point, javaScriptReplyProxy is null and the old evaluateJavascript path is used instead.
Expected Behavior
All plugin calls of the new page should go through the updated proxy.
Project Reproduction
Reproduced in a private repo
Additional Information
The bug is avoidable with android.useLegacyBridge = true as this routes every response through evaluateJavascriptand avoids the proxy entirely.
I've locally fixed the bug by swapping the two lines above, i.e., making sure the proxy is updated before the message post.
- 主要语言
- TypeScript
- 星标
- 16.7k
- 派生
- 1.3k
- 平均合并
- 3 天 10 小时
- 30 天内合并 PR
- 10
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ionic-team/capacitor 的其他 Issue
-
triage
难度 2/5 1-3 小时 新手友好度 78/100
ionic-team/capacitor#8601 ·
-
triage
难度 2/5 1-3 小时 新手友好度 68/100
ionic-team/capacitor#8574 ·
-
SystemBars: safe area CSS injection throws "Cannot read properties of null" on startup (Android 16) 未关闭triage
难度 2/5 1-3 小时 新手友好度 78/100
ionic-team/capacitor#8530 · 2 条评论 ·
-
triage
难度 2/5 1-3 小时 新手友好度 78/100
ionic-team/capacitor#8529 ·
-
needs reproduction
难度 2/5 1-3 小时 新手友好度 68/100
ionic-team/capacitor#8472 · 2 条评论 · 1 个 reaction ·
查看 ionic-team/capacitor 的全部 Issue
相似的 Issue
-
calcite-components needs triage refactor
难度 2/5 1-3 小时 新手友好度 75/100
Esri/calcite-design-system#15203 ·
-
难度 2/5 1-3 小时 新手友好度 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 2/5 1-3 小时 新手友好度 78/100
Automattic/studio#4908 ·
-
难度 2/5 1-3 小时 新手友好度 90/100