UnitySendMessage() Crashes with strings bigger than 1MB

未关闭
#67 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
android, unity
领域
mobile-dev

调研方向

The report identifies mUnityPlayer.UnitySendMessage() and provides Android crash signals, but names no source file or test. Start by locating the Unity-to-Android override and tracing how it handles large strings; the reported failure occurs near 1 MB. Done means large strings can be delivered without crashing, with a regression test or reproducible verification for the reported size.

由索引模型根据 Issue 内容生成。

描述

I am able to send any sizes of strings from Unity to AndroidStudio via override, but I get a crash you you try to send any string close or bigger than 1MB using the mUnityPlayer.UnitySendMessage() method.

This issue was very hard to track, after some debugging the maximum string length I could safely deliver was 1047500. (actually you can fit 1,048,576 characters on 1MB but anything above 1,047,500 may or not crash)
Since there is no fix to this and just one old comment on the forum... (yeah I've lost the link to that)

The workaround:
The way to get around it was to divide the strings into pieces of 1 million or less.
Upon sending the data to Unity I send a message (JSON) to a method saying how many parts it has.
Then I use a cached StringBuilder to append all the parts. Upon appending the last part I proceed with my usual code using the full string.

As this is a private project I will post just a part of the error:

E/CRASH: signal 7 (SIGBUS), code 2 (BUS_ADRERR), fault addr 0x88e07000

E/CRASH: main thread is trapped; signum = 7
E/CRASH: main thread is trapped; signum = 7

E/CRASH: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
E/CRASH: Cause: null pointer dereference
主要语言
Objective-C++
星标
815
派生
252
平均合并
21 小时 42 分钟
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Unity-Technologies/uaal-example 的其他 Issue

查看 Unity-Technologies/uaal-example 的全部 Issue

相似的 Issue

更多 Mobile Dev Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。