Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在鸿蒙上用正式发布的证书打release包之后,提交审核时,鸿蒙反馈运行时会闪退(自己无法测试,因为在未审核通过时,自己无法安装正在发布的安装包) #1446

Closed
fengnudexiaoniao opened this issue Dec 3, 2024 · 12 comments

Comments

@fengnudexiaoniao
Copy link

Note:

An crash issue will be ignored & closed in a week without logs.

The language of MMKV

e.g. Objective-C, Swift, Java, or Kotlin

The version of MMKV

e.g. v1.2.2
Note: For versions older than the latest version, please upgrade before posting any issue.
We don't have much time for old version tech support.

The platform of MMKV

e.g. iOS or Android

报这个错误。主要原因是鸿蒙11月22号之后对内存修改做了限制。详情看这里https://developer.huawei.com/consumer/cn/doc/harmonyos-releases-V5/changelogs-for-all-apps-b031-V5

主要报错如下:

Reason:Signal:SIGABRT(SI_TKILL)@0x01317bdb000052ad from:21165:20020187
LastFatalMessage:../../third_party/dart/runtime/vm/virtual_memory_posix.cc: 469: error: mprotect failed: 22 (Invalid argument)
Fault thread info:
Tid:21196, Name:1.ui
#00 pc 00000000001990cc /system/lib/ld-musl-aarch64.so.1(raise+228)(ba282d4e0c9add4f48aa3ff367d51fc7)
#1 pc 0000000000146424 /system/lib/ld-musl-aarch64.so.1(abort+20)(ba282d4e0c9add4f48aa3ff367d51fc7)
#2 pc 0000000000a1b198 /data/storage/el1/bundle/libs/arm64/libflutter.so(e30f7bfe875c386c56ed3d53f7f3bc4b9d2986c1)
#3 pc 0000000000aeb2c4 /data/storage/el1/bundle/libs/arm64/libflutter.so(e30f7bfe875c386c56ed3d53f7f3bc4b9d2986c1)
#4 pc 0000000000aead2c /data/storage/el1/bundle/libs/arm64/libflutter.so(e30f7bfe875c386c56ed3d53f7f3bc4b9d2986c1)
#5 pc 0000000000a48318 /data/storage/el1/bundle/libs/arm64/libflutter.so(e30f7bfe875c386c56ed3d53f7f3bc4b9d2986c1)
#6 pc 0000000000a48750 /data/storage/el1/bundle/libs/arm64/libflutter.so(e30f7bfe875c386c56ed3d53f7f3bc4b9d2986c1)
#7 pc 0000000000a302f0 /data/storage/el1/bundle/libs/arm64/libflutter.so(e30f7bfe875c386c56ed3d53f7f3bc4b9d2986c1)
#8 pc 0000000000a62a90 /data/storage/el1/bundle/libs/arm64/libflutter.so(e30f7bfe875c386c56ed3d53f7f3bc4b9d2986c1)
#9 pc 0000000000a62cc0 /data/storage/el1/bundle/libs/arm64/libflutter.so(e30f7bfe875c386c56ed3d53f7f3bc4b9d2986c1)

The installation of MMKV

e.g. Cocoapods, Maven, or Git clone

What's the issue?

Post the outputs or screenshots for errors.

Explain what you want by example or code in English.
If you have a crash/OOM/ANR on Android, please provide symbolize stack traces. https://developer.android.com/ndk/guides/ndk-stack.html

What's the log of MMKV when that happened?

Your detail logs. As much as possible.
For how to forward MMKV's log, you can checkout the wiki on each platform.
An crash issue will be ignored & closed in a week without logs.

@lingol
Copy link
Collaborator

lingol commented Dec 3, 2024

Why is it an MMKV issue? There's absolutely nothing to do with MMKV in your crash call-stacks.

@lingol lingol closed this as completed Dec 3, 2024
@lingol lingol closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2024
@fengnudexiaoniao
Copy link
Author

fengnudexiaoniao commented Dec 4, 2024

为什么是 MMKV 问题?您的崩溃调用堆栈中绝对与 MMKV 无关。

这个问题我们使用了排除法,kkmv库去掉之后,再打release包就不会闪退了,闪退和不闪退的包,除了去掉了MMKV库以外,其他没有任何变化 ,目前猜测可能是mmkv有一些初始化,即使没调用也会走到那里,触发了这个闪退,你们也可以测试下。打一个release让和你们对接的鸿蒙同事,安装测试下看看 ,使用的鸿蒙flutter sdk是3.22版本

@lingol
Copy link
Collaborator

lingol commented Dec 4, 2024

MMKV for flutter is already being used in WeChat on OHOS. We don't have that crash problem if that's what you are suggesting.

@lingol
Copy link
Collaborator

lingol commented Dec 4, 2024

Make sure you follow the official guide from OHOS.
PS: I don't think you can use flutter 3.22 as it looks like it's still 1.0.2 (based on 3.7.12) on gitee.

@fengnudexiaoniao
Copy link
Author

https://gitee.com/harmonycommando_flutter/flutter

Make sure you follow the official guide from OHOS. PS: I don't think you can use flutter 3.22 as it looks like it's still 1.0.2 (based on 3.7.12) on gitee.
这是3.22的连接地址
https://gitee.com/harmonycommando_flutter/flutter

@lingol
Copy link
Collaborator

lingol commented Dec 4, 2024

Then it would be reasonable if you complained about this crash to that repo instead of here.

@fengnudexiaoniao
Copy link
Author

fengnudexiaoniao commented Dec 4, 2024

那么如果你向那个 repo 而不是这里抱怨这次崩溃,那将是合理的。

鸿蒙的那边工程师反馈,mmkv插件源码里面有ffi的函数指针转换Pointer.fromFunction 这里可能有问题,你们可以联系对接下

@fengnudexiaoniao
Copy link
Author

Pointer.fromFunction 的底层实现依赖 Dart VM,主要分为以下几个步骤:
(1)生成 Dart 到原生的桥接代码
当你调用 Pointer.fromFunction 时,Dart VM 会生成一段桥接代码(trampoline),这段代码的作用是:
。将原生代码传入的参数转换为 Dart 类型
。调用 Dart 函数(在 Dart 堆栈上执行)。
·将 Dart 函数的返回值(如果有)转换回原生格式,并返回给调用者
这段桥接代码符合目标平台的 CABI,以确保原生代码可以直接调用

桥接代码的内存分配
Dart VM 会将桥接代码存储在!配的内存。分配的内存需要设置为 PROT EXEC
用。

鸿蒙的技术专家给的方案是可以避免调用这个函数指针转换,不要让dart假装自己是c函数,而是写一个c函数,用dartvm扩展,去调用那个dart函数,这样就不会有JIT了

@fengnudexiaoniao
Copy link
Author

那么如果你向那个 repo 而不是这里抱怨这次崩溃,那将是合理的。

遇到这种问题,再没有确定是那边的问题前,我一般两边都会反馈的, 鸿蒙工程师给出了一些建议,你们可以参考下。

@fengnudexiaoniao
Copy link
Author

微信已在 OHOS 上使用适用于 Flutter 的 MMKV。如果您说的是这种情况,那么我们没有遇到崩溃问题。

最终测试这句 触发了闪退,await MMKV.initialize(groupDir: groupDir, handler: JdMMKVHandler()); 去掉 handler:这参数,就不会闪退了.代码如下:

await MMKV.initialize(groupDir: groupDir) ,

猜测应该handler传递到c层,触发了 Pointer.fromFunction 函数

为了让你意识是你们适配鸿蒙代码的问题, 我们花了一个上午的时间去验证这个问题, 还是尽快解决下吧 。

@lingol
Copy link
Collaborator

lingol commented Dec 4, 2024

猜测应该handler传递到c层,触发了 Pointer.fromFunction 函数

为了让你意识是你们适配鸿蒙代码的问题, 我们花了一个上午的时间去验证这个问题, 还是尽快解决下吧 。

On the contrary, I think it's the OHOS Flutter team that didn't support my usage, which is an officially supported feature.

@lingol
Copy link
Collaborator

lingol commented Dec 4, 2024

For your information, and the OHOS Flutter team as well, iOS doesn't support creating MAP_ANONYMOUS memory with PROT_EXEC, yet Pointer.fromFunction works just fine on iOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants