我一直致力于一个社交媒体应用程序,该应用程序在KitKat及更低版本上运行的所有设备上运行良好。
我尝试在Lollipop和更高版本的OS上运行它并且它崩溃了。
经过数周的调试,我所拥有的仍然是一条错误消息,与我的代码无关:
GameObject
我在应用程序中绝对不使用本机代码。
可能是什么原因?
我尝试在代码中关闭硬件加速,这没有用。 当我尝试打开联系人列表时发生崩溃。我的联系人列表只有3张图像,它们的大小都在几十千字节之内。
最后,这是加载Bitmap的代码:
01-22 00:37:09.481 6661-6672/supernet.interactapp A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0x74616433 in tid 6672 (FinalizerDaemon)
01-22 00:37:09.480 6661-6676/supernet.interactapp I/art: Background sticky concurrent mark sweep GC freed 7891(375KB) AllocSpace objects, 4(64KB) LOS objects, 35% free, 723KB/1117KB, paused 39.238ms total 140.184ms
01-22 00:37:09.501 5229-5290/supernet.interactapp:remote E/Ultra Admin: retrieve messages called: CONNECTED
01-22 00:37:09.571 6661-6676/supernet.interactapp I/art: Background partial concurrent mark sweep GC freed 447(37KB) AllocSpace objects, 0(0B) LOS objects, 57% free, 764KB/1788KB, paused 6.993ms total 51.547ms
01-22 00:37:09.588 85-85/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-22 00:37:09.588 85-85/? I/DEBUG: Build fingerprint: 'generic/vbox86p/vbox86p:5.1/LMY47D/buildbot11172007:userdebug/test-keys'
01-22 00:37:09.588 85-85/? I/DEBUG: Revision: '0'
01-22 00:37:09.588 85-85/? I/DEBUG: ABI: 'x86'
01-22 00:37:09.588 85-85/? I/DEBUG: pid: 6661, tid: 6672, name: FinalizerDaemon >>> supernet.interactapp <<<
01-22 00:37:09.588 85-85/? I/DEBUG: signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x74616433
01-22 00:37:09.651 85-85/? I/DEBUG: eax 7461642f ebx f6352bac ecx 00000001 edx 70612f61
01-22 00:37:09.651 85-85/? I/DEBUG: esi f3e9ebe0 edi f3e9ebe0
01-22 00:37:09.652 85-85/? I/DEBUG: xcs 00000023 xds 0000002b xes 0000002b xfs 0000003f xss 0000002b
01-22 00:37:09.652 85-85/? I/DEBUG: eip f5fd09fb ebp 00000000 esp eebff950 flags 00210282
01-22 00:37:09.653 85-85/? I/DEBUG: #00 pc 001019fb /system/lib/libskia.so (SkBitmap::freePixels()+43)
01-22 00:37:09.653 85-85/? I/DEBUG: #01 pc 00101a6a /system/lib/libskia.so (SkBitmap::~SkBitmap()+26)
01-22 00:37:09.667 85-85/? I/DEBUG: #02 pc 000e02e3 /system/lib/libandroid_runtime.so
01-22 00:37:09.687 85-85/? I/DEBUG: #03 pc 0001d992 /data/dalvik-cache/x86/system@framework@boot.oat
01-22 00:37:09.697 85-85/? I/DEBUG: #04 pc 70612f60 <unknown>
01-22 00:37:09.704 85-85/? I/DEBUG: #05 pc 892cec82 <unknown>
01-22 00:37:09.740 85-85/? W/libbacktrace: virtual bool Backtrace::VerifyReadWordArgs(uintptr_t, word_t*): invalid pointer 0x74616437
什么可能导致这次崩溃?
更新
我注意到系统内存不足或原因可能是由于本机代码中发生了什么事情?
public static Bitmap decodeSampledBitmapFromFile(File data,
int reqWidth, int reqHeight) {
// First decode with inJustDecodeBounds=true to check dimensions
final BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(data.getAbsolutePath(), options);
// Calculate inSampleSize
options.inSampleSize = calculateInSampleSize(options, reqWidth,
reqHeight);
// Decode bitmap with inSampleSize set
options.inJustDecodeBounds = false;
return BitmapFactory.decodeFile(data.getAbsolutePath(), options);
}
更新
我使用Android 6.0 MarshMallow在Infinix X510上运行应用程序,我收到错误:
01-23 10:30:31.561 2106-2121/? I/art: Background sticky concurrent mark
sweep GC freed 7418(355KB) AllocSpace objects, 3(48KB) LOS objects, 1% free,
21MB/21MB, paused 7.940ms total 40.757ms
和
stacktrace:
01-23 20:13:12.418 5592-5600/? A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 5600 (FinalizerDaemon)
01-23 20:13:12.474 5695-5695/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-23 20:13:12.474 5695-5695/? A/DEBUG: Build fingerprint: 'Infinix/Infinix_X510/Infinix_X510_sprout:6.0/MRA58K/1452855576:user/release-keys'
01-23 20:13:12.474 5695-5695/? A/DEBUG: Revision: '0'
01-23 20:13:12.475 5695-5695/? A/DEBUG: ABI: 'arm'
01-23 20:13:12.475 5695-5695/? A/DEBUG: pid: 5592, tid: 5600, name: FinalizerDaemon >>> supernet.interactapp <<<
01-23 20:13:12.475 5695-5695/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0
01-23 20:13:12.499 5695-5695/? A/DEBUG: r0 afa193c0 r1 afa193a0 r2 00000000 r3 00000000
01-23 20:13:12.499 5695-5695/? A/DEBUG: r4 ae67bfe0 r5 00000001 r6 ffffffff r7 ffffffff
01-23 20:13:12.499 5695-5695/? A/DEBUG: r8 00000000 r9 ab5de800 sl 00000000 fp 12e69e40
01-23 20:13:12.499 5695-5695/? A/DEBUG: ip b5c804b4 sp b3c5e528 lr b6e9add7 pc 00000000 cpsr 40070010
01-23 20:13:12.500 5695-5695/? E/AEE/LIBAEE: aee_try_get_word: read:5600 addr:0x00000000 ret:-1, 5
01-23 20:13:12.503 5695-5695/? A/DEBUG: #00 pc 00000000 <unknown>
01-23 20:13:12.503 5695-5695/? A/DEBUG: #01 pc 0008fdd5 /system/lib/libandroid_runtime.so (android::Bitmap::~Bitmap()+20)
01-23 20:13:12.503 5695-5695/? A/DEBUG: #02 pc 0008fdff /system/lib/libandroid_runtime.so (android::Bitmap::detachFromJava()+30)
01-23 20:13:12.503 5695-5695/? A/DEBUG: #03 pc 72a75785 /data/dalvik-cache/arm/system@framework@boot.oat (offset 0x23a4000)
01-23 20:13:12.808 5695-5695/? E/DEBUG: waitpid failed: tid 5592, No child processes
答案 0 :(得分:1)
加载位图时,您是否检查了设备的内存?我知道你正在计算inSampleSize,但是我遇到了同样的问题,因为我将错误的值传递给参数reqWidth和reqHeight,当然,inSampleSize是大而崩溃的设备内存。此问题出现在照片库中。
我希望这有帮助!