Tiny icon indicating copy to clipboard operation
Tiny copied to clipboard

遇到一个 SIGABRT 这样的错误

Open pardonhan opened this issue 7 years ago • 2 comments

我在项目中使用了腾讯的bugly插件,给我返回了一个标题为 SIGABRT 这个的错误。机型是 荣耀 CAM TL00 Android 6.0

1 #00 pc 000000000006aec4 /system/lib64/libc.so (tgkill+8) [arm64-v8a]
2 #01 pc 00000000000690a4 /system/lib64/libc.so (pthread_kill+68) [arm64-v8a]
3 #02 pc 000000000002208c /system/lib64/libc.so (raise+28) [arm64-v8a]
4 #03 pc 000000000001c998 /system/lib64/libc.so (abort+60) [arm64-v8a]
5 #04 pc 000000000040e728 /system/lib64/libart.so (art::Runtime::Abort()+324) [arm64-v8a]
6 #05 pc 000000000010dfa4 /system/lib64/libart.so (art::LogMessage::~LogMessage()+3136) [arm64-v8a]
7 #06 pc 00000000002e76a0 /system/lib64/libart.so (art::JavaVMExt::JniAbort(char const*, char const*)+2080) [arm64-v8a]
8 #07 pc 00000000002e7b20 /system/lib64/libart.so (art::JavaVMExt::JniAbortV(char const*, char const*, std::__va_list)+116) [arm64-v8a]
9 #08 pc 0000000000119ddc /system/lib64/libart.so (art::JValue art::interpreter::ExecuteSwitchImpl<true, false>(art::Thread*, art::DexFile::CodeItem const*, art::ShadowFrame&, art::JValue)+48684) [arm64-v8a]
10 #09 pc 0000000000120c8c /system/lib64/libart.so (art_quick_set_obj_instance+12) [arm64-v8a]
11 #10 pc 000000000013a4cc /system/lib64/libart.so (art::ReaderWriterMutex::ExclusiveLockWithTimeout(art::Thread*, long, int)+452) [arm64-v8a]
12 #11 pc 000000000013ad54 /system/lib64/libart.so (art::ConditionVariable::WaitHoldingLocks(art::Thread*)+632) [arm64-v8a]
13 #12 pc 00000000000c3d9c /system/lib64/libandroid_runtime.so (doDecode(_JNIEnv*, SkStreamRewindable*, _jobject*, _jobject*)+1060) [arm64-v8a]
14 #13 pc 00000000000c45a4 /system/lib64/libandroid_runtime.so (android::NativeInputEventSender::initialize()+40) [arm64-v8a]
15 #14 pc 00000000032e2210 /data/dalvik-cache/arm64/system@[email protected] (oatexec+15000080) [arm64-v8a]
16 java:
17 android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:580)
18 com.zxy.tiny.core.BitmapCompressor.sampleCompress(BitmapCompressor.java:228)
19 com.zxy.tiny.core.BitmapCompressor.compress(BitmapCompressor.java:106)
20 com.zxy.tiny.core.FileCompressor.compress(FileCompressor.java:38)
21 com.zxy.tiny.callable.FileCompressCallableTasks$FileAsFileCallable.call(FileCompressCallableTasks.java:76)
22 com.zxy.tiny.callable.FileCompressCallableTasks$FileAsFileCallable.call(FileCompressCallableTasks.java:60)
23 java.util.concurrent.FutureTask.run(FutureTask.java:237)
24 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
25 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
26 com.zxy.tiny.core.CompressThreadFactory$1.run(CompressThreadFactory.java:28)
27 java.lang.Thread.run(Thread.java:833)
28 java pending exception:
29 [Native crash above happened with a java pending exception as following]
30 java.lang.OutOfMemoryError: Failed to allocate a 12979212 byte allocation with 4194304 free bytes and 11MB until OOM
31 android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method)
32 android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:580)
33 com.zxy.tiny.core.BitmapCompressor.sampleCompress(BitmapCompressor.java:228)
34 com.zxy.tiny.core.BitmapCompressor.compress(BitmapCompressor.java:106)
35 com.zxy.tiny.core.FileCompressor.compress(FileCompressor.java:38)
36 com.zxy.tiny.callable.FileCompressCallableTasks$FileAsFileCallable.call(FileCompressCallableTasks.java:76)
37 com.zxy.tiny.callable.FileCompressCallableTasks$FileAsFileCallable.call(FileCompressCallableTasks.java:60)
38 java.util.concurrent.FutureTask.run(FutureTask.java:237)
39 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
40 java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
41 com.zxy.tiny.core.CompressThreadFactory$1.run(CompressThreadFactory.java:28)
42 java.lang.Thread.run(Thread.java:833)

下面是腾讯的Bugly给出的解决方案。

解决方案
abort program
SIG是信号名的通用前缀。ABRT是abort program的缩写。

当操作系统发现不安全的情况时,它能够对这种情况进行更多的控制,必要的话,它能要求进程进行清理工作。在调试造成此信号的底层错误时,并没有什么妙招。 如 cocos2d 或 UIKit 等框架通常会在特定的前提条件没有满足或一些糟糕的情况出现时调用 C 函数 abort (由它来发送此信号)。

如果是iOS系统:
发生在UIApplication WillTerminate 时,是主动退出应用时发生的,所以对用户没什么实际影响。
iOS10访问相册时发生,目前只发生在iOS10+系统,需要修改工程plist文件,加入访问权限提示信息。
补充:iOS 10 has updated privacy policy and implemented new privacy rules. You have to update your Info.plist app with this following fields by authorisation asked.

pardonhan avatar May 31 '17 00:05 pardonhan

@pardonhan 这是一个OutOfMemoryError,在进行压缩时候内存分配不足导致OOM,Failed to allocate a 12979212 byte allocation with 4194304 free bytes and 11MB until OOM,猜想你应该对压缩的图片没有使用内部的自适应设置。可以贴下你的压缩代码。

Sunzxyong avatar May 31 '17 02:05 Sunzxyong

 private Bitmap.Config mConfig = Bitmap.Config.RGB_565;

 private void compressImg() {

        Tiny.FileCompressOptions compressOptions = new Tiny.FileCompressOptions();
        compressOptions.config = mConfig;
        Tiny.getInstance().source(filePath + "" + picTakeName).asFile().withOptions(compressOptions).compress(new FileCallback() {
            @Override
            public void callback(boolean isSuccess, String outfile) {
                if (!isSuccess) {
                    handler.sendEmptyMessage(3);
                    return;
                }
                handler.sendMessage(handler.obtainMessage(2, outfile));
            }
        });
    }

pardonhan avatar Jun 14 '17 09:06 pardonhan