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

Pag 在一些机型上偶现Crash #789

Closed
memorycj opened this issue Mar 15, 2023 · 8 comments
Closed

Pag 在一些机型上偶现Crash #789

memorycj opened this issue Mar 15, 2023 · 8 comments
Assignees
Labels
question This is a usage question

Comments

@memorycj
Copy link

libpag 版本

libpag 4.1.43

平台

Android

分布平台

image
系统版本
image

crash日志栈

#79164049 SIGSEGV(SEGV_MAPERR)
1 #00 pc 000000000041df70 /system/lib64/egl/libGLES_mali.so [arm64-v8a::c49381dbe83bca18922ea39e468 8a6aa]
2 2
3 #1 pc 0000000000415ca0 /system/lib64/egl/libGLES_mali.so [arm64-v8a::c49381dbe83bca18922ea39e468 8a6aa]
4 3
5 #2 pc 0000000000414bf8 /system/lib64/egl/libGLES_mali.so [arm64-v8a::c49381dbe83bca18922ea39e468 8a6aa]
6 4
7 #3 pc 0000000000416248 /system/lib64/egl/libGLES_mali.so [arm64-v8a::c49381dbe83bca18922ea39e468 8a6aa]
8 5
9 #4 pc 00000000004163e0 /system/lib64/egl/libGLES_mali.so [arm64-v8a::c49381dbe83bca18922ea39e468 8a6aa]
10 6
11 #5 pc 0000000000417d88 /system/lib64/egl/libGLES_mali.so [arm64-v8a::c49381dbe83bca18922ea39e468 8a6aa]
12 7
13 #6 pc 0000000000608874 /system/lib64/egl/libGLES_mali.so [arm64-v8a::c49381dbe83bca18922ea39e468 8a6aa]
14 8
15 #7 pc 0000000000607e8c /system/lib64/egl/libGLES_mali.so [arm64-v8a::c49381dbe83bca18922ea39e468 8a6aa]
16 9
17 #8 pc 000000000060600c /system/lib64/egl/libGLES_mali.so [arm64-v8a::c49381dbe83bca18922ea39e468 8a6aa]
18 10
19 #9 pc 000000000018b6b8 /data/app/xxxxx/lib/arm64/libpag.so [arm64 -v8a::2211310c153d7a40eacb033fad1510f7]
20 11
21 #10 pc 000000000018b56c /data/app/xxxxx/lib/arm64/libpag.so [arm64 -v8a::2211310c153d7a40eacb033fad1510f7]
22 #11 pc 00000000001898c0 /data/app/xxxxx/lib/arm64/libpag.so [arm64 -v8a::2211310c153d7a40eacb033fad1510f7]
23 13
24 #12 pc 0000000000105eec /data/app/xxxxx/lib/arm64/libpag.so [arm64 -v8a::2211310c153d7a40eacb033fad1510f7]
25 14
26 #13 pc 00000000000f2a7c /data/app/xxxxx/lib/arm64/libpag.so [arm64 -v8a::2211310c153d7a40eacb033fad1510f7]
27 15
28 #14 pc 0000000000091d88 /data/app/xxxxx/lib/arm64/libpag.so (pag:: PAGSurface::draw(pag::RenderCache*, std::__ndk1::shared_ptrpag::Graphic, pag::BackendSemaphore* , bool)+456) [arm64-v8a::2211310c153d7a40eacb033fad1510f7]
29 16
22 #11 pc 00000000001898c0 /data/app/xxxxx/lib/arm64/libpag.so [arm64-v8a::2211310c153d7a40eacb033fad1 510f7]
23 13
24 #12 pc 0000000000105eec /data/app/xxxxx/lib/arm64/libpag.so [arm64-v8a::2211310c153d7a40eacb033fad1 510f7]
25 14
26 #13 pc 00000000000f2a7c /data/app/xxxxx/lib/arm64/libpag.so [arm64-v8a::2211310c153d7a40eacb033fad1 510f7]
27 15
28 #14 pc 0000000000091d88 /data/app/xxxxx/lib/arm64/libpag.so (pag::PAGSurface::draw(pag::RenderCache , std::__ndk1::shared_ptrpag::Graphic, pag::BackendSemaphore, bool)+456) [arm64-v8a::2211310c153d7a40eacb033fad1510f7]
29 16
30 #15 pc 00000000000900bc /data/app/xxxxx/lib/arm64/libpag.so (pag::PAGPlayer::flushInternal(pag::Bac kendSemaphore*)+208) [arm64-v8a::2211310c153d7a40eacb033fad1510f7]
31 17
32 #16 pc 000000000008ffb4 /data/app/xxxxx/lib/arm64/libpag.so (pag::PAGPlayer::flush()+88) [arm64-v8a ::2211310c153d7a40eacb033fad1510f7]
33 18
34 #17 pc 00000000000e8b18 /data/app/xxxxx/lib/arm64/libpag.so (Java_org_libpag_PAGPlayer_flushAndFenc eSync+204) [arm64-v8a::2211310c153d7a40eacb033fad1510f7]
35 19
36 #18 pc 0000000007cb2ef8 /data/app/xxxxx/oat/arm64/base.odex (oatexec+18996984) [arm64-v8a::dd8ea0e9 df29d7ae8de12e3653b91823]
37 20
38 java:
39 21
40 org.libpag.PAGPlayer.boolean flush()(PAGPlayer.java)
41 22
42 org.libpag.PAGView.boolean flush()(PAGView.java:814)
43 23
44 org.libpag.PAGView.void updateView()(PAGView.java:364)
45 24
46 org.libpag.PAGView.void access$000(org.libpag.PAGView)(PAGView.java)
47 25
48 org.libpag.PAGView$PAGViewHandler.void handleMessage(android.os.Message)(PAGView.java:170)
49 26
50 android.os.Handler.dispatchMessage(Handler.java:111)
51 27
52 android.os.Looper.loop(Looper.java:227)
53 28
54 android.os.HandlerThread.run(HandlerThread.java:61)

问题线程: pag-renderer(2085)

PAG File

未定位

@domchen
Copy link
Collaborator

domchen commented Mar 16, 2023

这个堆栈没有有效信息,每个版本都有对应的obj符号包,https://github.com/Tencent/libpag/releases 下载符号包上传到你们crash堆栈的上报工具里,转换成可以阅读的堆栈信息才能看问题。

@peter100u
Copy link

这个应该还是性能问题,pagview太多导致的,flush调用太多到handler

@domchen domchen added the question This is a usage question label Mar 29, 2023
@zhuanghongji
Copy link

zhuanghongji commented Apr 12, 2023

发现 PAG V4.2.20 版本在 Android 7.1.1 上会闪退(Bugly 日志和设备信息如下)

注:Android 8 和 Android 8.1.0 及以上不会闪退

# main(19526)

SIGABRT

解析原始
1
#00 pc 000000000006baa8 /system/lib64/libc.so (tgkill+8) [arm64-v8a::e65dbe3732f0b1cefe26738aae64b87b]
2
#01 pc 0000000000068f2c /system/lib64/libc.so (pthread_kill+64) [arm64-v8a::e65dbe3732f0b1cefe26738aae64b87b]
3
#02 pc 0000000000024180 /system/lib64/libc.so (raise+24) [arm64-v8a::e65dbe3732f0b1cefe26738aae64b87b]
4
#03 pc 000000000001cbec /system/lib64/libc.so (abort+52) [arm64-v8a::e65dbe3732f0b1cefe26738aae64b87b]
5
#04 pc 0000000000431188 /system/lib64/libart.so (art::Runtime::Abort(char const*)+456) [arm64-v8a::379a9e8f0466656efdf51a00432cd95a]
6
#05 pc 00000000000e5e18 /system/lib64/libart.so (art::LogMessage::~LogMessage()+1576) [arm64-v8a::379a9e8f0466656efdf51a00432cd95a]
7
#06 pc 00000000002ef4d8 /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+2172) [arm64-v8a::379a9e8f0466656efdf51a00432cd95a]
8
#07 pc 00000000002ef89c /system/lib64/libart.so (art::JavaVMExt::JniAbortF(char const*, char const*, ...)+184) [arm64-v8a::379a9e8f0466656efdf51a00432cd95a]
9
#08 pc 000000000032bfec /system/lib64/libart.so (art::JNI::NewObjectV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+916) [arm64-v8a::379a9e8f0466656efdf51a00432cd95a]
10
#09 pc 00000000000cde60 /data/app/com.package.name-1/lib/arm64/libpag.so [arm64-v8a::3b6c2757bad9728e552192423def7c56]
11
#10 pc 00000000000cecc4 /data/app/com.package.name-1/lib/arm64/libpag.so [arm64-v8a::3b6c2757bad9728e552192423def7c56]
12
#11 pc 00000000000d15e4 /data/app/com.package.name-1/lib/arm64/libpag.so (Java_org_libpag_PAGFile_LoadFromBytes+220) [arm64-v8a::3b6c2757bad9728e552192423def7c56]
13
#12 pc 0000000001a196b0 /data/app/com.package.name-1/oat/arm64/base.odex (oatexec+2115248) [arm64-v8a::15050000000000000000000000000000]
设备信息:
- 前后台状态:前台
- 系统版本:Android 7.1.1,level 25
- ROM:Oppo/COLOROS
- CPU架构:arm64-v8a

补充闪退日志如下(可确定在 Android 8.1 及以上正常,8.0 及以下会闪退):

A  java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: mid == null
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]     in call to NewObjectV
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]     from org.libpag.PAGFile org.libpag.PAGFile.LoadFromBytes(byte[], int)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504] "main" prio=5 tid=1 Runnable
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   | group="main" sCount=0 dsCount=0 flags=0 obj=0x73791670 self=0x74624bea00
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   | sysTid=5067 nice=-4 cgrp=default sched=0/0 handle=0x7466cf09b0
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   | state=R schedstat=( 2941725064 1033611124 6866 ) utm=236 stm=58 core=1 HZ=100
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   | stack=0x7ffc3b8000-0x7ffc3ba000 stackSize=8MB
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   | held mutexes= "mutator lock"(shared held)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #00 pc 0000000000396fb4  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+212)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #01 pc 000000000045d208  /system/lib64/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMapb+348)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #02 pc 00000000002d53a4  /system/lib64/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1040)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #03 pc 00000000002d5914  /system/lib64/libart.so (_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+176)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #04 pc 00000000003173e4  /system/lib64/libart.so (_ZN3art3JNI10NewObjectVEP7_JNIEnvP7_jclassP10_jmethodIDSt9__va_list+908)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #05 pc 00000000000cde60  /data/app/com.package.name-P9rP0IjU_gu6QGGtK77hSQ==/lib/arm64/libpag.so (???)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #06 pc 00000000000cecc4  /data/app/com.package.name-P9rP0IjU_gu6QGGtK77hSQ==/lib/arm64/libpag.so (???)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #07 pc 00000000000d15e4  /data/app/com.package.name-P9rP0IjU_gu6QGGtK77hSQ==/lib/arm64/libpag.so (Java_org_libpag_PAGFile_LoadFromBytes+220)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #08 pc 0000000000208d04  /data/app/com.package.name-P9rP0IjU_gu6QGGtK77hSQ==/oat/arm64/base.odex (Java_org_libpag_PAGFile_LoadFromBytes___3BI+180)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   at org.libpag.PAGFile.LoadFromBytes(Native method)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   at org.libpag.PAGFile.Load(SourceFile:2)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   at com.package.name.components.pag.PAGViewManager.setSrc(PAGViewManager.java:198)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   at java.lang.reflect.Method.invoke(Native method)

补充闪退日志如下(可确定在 Android 8.1 及以上正常,8.0 及以下会闪退):

           A  java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: mid == null
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]     in call to NewObjectV
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]     from org.libpag.PAGFile org.libpag.PAGFile.LoadFromBytes(byte[], int)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504] "main" prio=5 tid=1 Runnable
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   | group="main" sCount=0 dsCount=0 flags=0 obj=0x73791670 self=0x74624bea00
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   | sysTid=5067 nice=-4 cgrp=default sched=0/0 handle=0x7466cf09b0
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   | state=R schedstat=( 2941725064 1033611124 6866 ) utm=236 stm=58 core=1 HZ=100
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   | stack=0x7ffc3b8000-0x7ffc3ba000 stackSize=8MB
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   | held mutexes= "mutator lock"(shared held)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #00 pc 0000000000396fb4  /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+212)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #01 pc 000000000045d208  /system/lib64/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMapb+348)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #02 pc 00000000002d53a4  /system/lib64/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1040)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #03 pc 00000000002d5914  /system/lib64/libart.so (_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+176)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #04 pc 00000000003173e4  /system/lib64/libart.so (_ZN3art3JNI10NewObjectVEP7_JNIEnvP7_jclassP10_jmethodIDSt9__va_list+908)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #05 pc 00000000000cde60  /data/app/com.package.name-P9rP0IjU_gu6QGGtK77hSQ==/lib/arm64/libpag.so (???)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #06 pc 00000000000cecc4  /data/app/com.package.name-P9rP0IjU_gu6QGGtK77hSQ==/lib/arm64/libpag.so (???)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #07 pc 00000000000d15e4  /data/app/com.package.name-P9rP0IjU_gu6QGGtK77hSQ==/lib/arm64/libpag.so (Java_org_libpag_PAGFile_LoadFromBytes+220)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   native: #08 pc 0000000000208d04  /data/app/com.package.name-P9rP0IjU_gu6QGGtK77hSQ==/oat/arm64/base.odex (Java_org_libpag_PAGFile_LoadFromBytes___3BI+180)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   at org.libpag.PAGFile.LoadFromBytes(Native method)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   at org.libpag.PAGFile.Load(SourceFile:2)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   at com.package.name.components.pag.PAGViewManager.setSrc(PAGViewManager.java:198)
2023-04-12 15:55:42.310 zygote64                 A  java_vm_ext.cc:504]   at java.lang.reflect.Method.invoke(Native method)

@domchen
Copy link
Collaborator

domchen commented Apr 13, 2023

从日志上看,好像是Java方法没有找到的原因,你是不是接入使用的时候没有按照接入文档设置混淆的过滤?我们已经混淆了所有可以混淆的Java代码,业务上需要全部keep住剩下的Java类,否则C++反射都会失败。可以参考一下:https://github.com/Tencent/libpag/wiki/mobile-sdk-guide 使用规则跳过混淆:
-keep class org.libpag.** {*;} -keep class androidx.exifinterface.** {*;}

另外还发现一个可疑的地方,你是自己修了 Java的代码吗?我们并不存在 at org.libpag.PAGFile.Load(SourceFile:2) 这个方法。

@zhuanghongji
Copy link

从日志上看,好像是Java方法没有找到的原因,你是不是接入使用的时候没有按照接入文档设置混淆的过滤?我们已经混淆了所有可以混淆的Java代码,业务上需要全部keep住剩下的Java类,否则C++反射都会失败。可以参考一下:https://github.com/Tencent/libpag/wiki/mobile-sdk-guide 使用规则跳过混淆: -keep class org.libpag.** {*;} -keep class androidx.exifinterface.** {*;}

另外还发现一个可疑的地方,你是自己修了 Java的代码吗?我们并不存在 at org.libpag.PAGFile.Load(SourceFile:2) 这个方法。

@domchen

1、混淆是加了的,否则 Android 8.1 及以上的 release 包也会闪退。
2、估计因为混淆,闪退日志里的方法名跟实际可能不完全对应,实际对应关系大致如下:

org.libpag.PAGFile.Load(SourceFile:2)

// 对应:

public class PAGFile extends PAGComposition {
    private static native PAGFile LoadFromBytes(byte[] var0, int var1);
}
org.libpag.PAGFile.Load(SourceFile:3)

// 对应:

public class PAGFile extends PAGComposition {
    private static native PAGFile LoadFromAssets(AssetManager var0, String var1);
}

可以在 Android 8.0.0 及以下版本的系统上复现的核心代码:

// 1
pagView.setComposition(PAGFile.Load(rawBytes));

// 2
PAGFile pagFile = PAGFile.Load(context.getAssets(), "mo_matter_what_name.pag");
pagView.setComposition(pagFile);

特别说明:

  • 重现此问题的是一个 React Native 项目来的(我封装了一个 PAG 的 React Native 原生组件)。
  • 个人认为这个应该跟 React Native 没关系,所以就没有在 Android 7.1.1 的模拟器上跑纯 Android 原生项目去验证这个问题。
  • 另外,这可能跟低版本 Android 系统的兼容问题有关?因为在我注释了上述的 PAGFile.LoadpagView.setComposition 逻辑后,在 Android 7.1.1 模拟器上还发现了其它闪退问题,日志大致为:java.lang.NoSuchFieldError: no "Landroid/graphics/Bitmap$Config;" field "HARDWARE" in class "Landroid/graphics/Bitmap$Config;" or its superclasses

@domchen
Copy link
Collaborator

domchen commented Apr 15, 2023

Bitmap带Hardware的问题最新版本4.2的最新版本里已经修复过。你原本遇到的这个crash看起来比较大概率还是自定义封装造成的,因为基本没有其他业务反馈过在那个位置可能发生崩溃,而且从原版的代码review里也找不出来有可能crash的地方,除了混淆的问题,但是你也说这个可以排除。那建议是在安卓原生平台尝试一下看看是否能复现,可以排除是不是自己封装的组件的问题。

@zhuanghongji
Copy link

Bitmap带Hardware的问题最新版本4.2的最新版本里已经修复过。你原本遇到的这个crash看起来比较大概率还是自定义封装造成的,因为基本没有其他业务反馈过在那个位置可能发生崩溃,而且从原版的代码review里也找不出来有可能crash的地方,除了混淆的问题,但是你也说这个可以排除。那建议是在安卓原生平台尝试一下看看是否能复现,可以排除是不是自己封装的组件的问题。

@domchen
1、不是 React Native 封装的问题,PAG V4.2.20 在 Android 原生上直接使用 PAGView 时,Android 8.0 及以下也会闪退。
2、将 PAG 升级到前两周发的 V4.2.55 之后,Android 8.0 以下的闪退问题就没有了,个人认为这个 issue 应该可以关了。

@domchen domchen closed this as completed Apr 26, 2023
@domchen
Copy link
Collaborator

domchen commented Apr 26, 2023

Bitmap 带 Hardware 的问题确实就是8.0以下才会遇到,符合问题的具体表现,你遇到的大概率就是这个问题。可能是之前的日志堆栈都没对上正确的函数符号,有点迷惑性。估计是用来解析符号的那个obj版本号和你实际运行的版本号可能不一致。否则不会解出来是loadFromBytes那个入口。

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

No branches or pull requests

4 participants