解散API 23中的Dialog时出现DeadObjectException

时间:2016-01-06 23:02:15

标签: android android-dialogfragment android-6.0-marshmallow

我刚刚将我的项目升级到API 23,并且我在以前一直有效的代码上遇到错误。当我在下面的Spinner监听器中调用dismiss时发生崩溃。如果我不在这个区域内调用void showWeekViewOptionsDialog() { AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); final View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_weekview_options, null); final MaterialSpinnerCallsSameItemSelected spinner = (MaterialSpinnerCallsSameItemSelected) view.findViewById(R.id.spinner_weekview_days); ArrayAdapter<Integer> dayListAdapter; ArrayList<Integer> dayList = new ArrayList<Integer>(); dayList.add(2); dayList.add(3); dayListAdapter = new ArrayAdapter<Integer>(getActivity(), R.layout.my_spinner_item, dayList); dayListAdapter.setDropDownViewResource(R.layout.my_spinner_dropdown_item); spinner.setAdapter(dayListAdapter); spinner.setSelection(dayListAdapter.getPosition(mWeekViewType)); b.setView(view); final AlertDialog dialog = b.create(); spinner.setOnItemSelectedEvenIfUnchangedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { dialog.dismiss(); // crashes here! } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); dialog.show(); } ,它不会崩溃。

01-06 17:53:45.791 4436-4485/com.NSouthDomain.NSouthApplication E/Surface: getSlotFromBufferLocked: unknown buffer: 0x9c359200
01-06 17:53:46.066 1278-1303/system_process W/WindowManager: Force-removing child win Window{df5d861 u0 PopupWindow:ac39394} from container Window{d72786b u0 com.NSouthDomain.NSouthApplication/com.NSouthDomain.NSouthApplication.Activity_Main}
01-06 17:53:46.087 941-1963/? E/BufferQueueProducer: [PopupWindow:ac39394] dequeueBuffer: BufferQueue has been abandoned
01-06 17:53:46.089 941-941/? W/SurfaceFlinger: couldn't log to binary event log: overflow.
01-06 17:53:46.090 4436-4485/com.NSouthDomain.NSouthApplication E/EGL_emulation: tid 4485: swapBuffers(322): error 0x3003 (EGL_BAD_ALLOC)
01-06 17:53:46.090 4436-4485/com.NSouthDomain.NSouthApplication A/OpenGLRenderer: Encountered EGL error 12291 EGL_BAD_ALLOC during rendering
01-06 17:53:46.090 4436-4485/com.NSouthDomain.NSouthApplication A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 4485 (RenderThread)
01-06 17:53:46.208 949-949/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
01-06 17:53:46.208 949-949/? A/DEBUG: Build fingerprint: 'Android/sdk_google_phone_x86/generic_x86:6.0/MASTER/2497369:userdebug/test-keys'
01-06 17:53:46.208 949-949/? A/DEBUG: Revision: '0'
01-06 17:53:46.208 949-949/? A/DEBUG: ABI: 'x86'
01-06 17:53:46.208 949-949/? A/DEBUG: pid: 4436, tid: 4485, name: RenderThread  >>> com.NSouthDomain.NSouthApplication <<<
01-06 17:53:46.208 949-949/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
01-06 17:53:46.210 949-949/? A/DEBUG: Abort message: 'Encountered EGL error 12291 EGL_BAD_ALLOC during rendering'
01-06 17:53:46.211 949-949/? A/DEBUG:     eax 00000000  ebx 00001154  ecx 00001185  edx 00000006
01-06 17:53:46.211 949-949/? A/DEBUG:     esi a2cbf980  edi 0000000b
01-06 17:53:46.211 949-949/? A/DEBUG:     xcs 00000073  xds 0000007b  xes 0000007b  xfs 00000077  xss 0000007b
01-06 17:53:46.211 949-949/? A/DEBUG:     eip b7304696  ebp 00001185  esp a2cbf150  flags 00200202
01-06 17:53:46.211 949-949/? A/DEBUG:     #00 pc 00083696  /system/lib/libc.so (tgkill+22)
01-06 17:53:46.212 949-949/? A/DEBUG:     #01 pc 000815e8  /system/lib/libc.so (pthread_kill+70)
01-06 17:53:46.212 949-949/? A/DEBUG:     #02 pc 00027205  /system/lib/libc.so (raise+36)
01-06 17:53:46.212 949-949/? A/DEBUG:     #03 pc 000209e4  /system/lib/libc.so (abort+80)
01-06 17:53:46.212 949-949/? A/DEBUG:     #04 pc 0000cbc3  /system/lib/libcutils.so (__android_log_assert+128)
01-06 17:53:46.212 949-949/? A/DEBUG:     #05 pc 00023759  /system/lib/libhwui.so
01-06 17:53:46.212 949-949/? A/DEBUG:     #06 pc 0001e866  /system/lib/libhwui.so
01-06 17:53:46.212 949-949/? A/DEBUG:     #07 pc 000216ef  /system/lib/libhwui.so
01-06 17:53:46.212 949-949/? A/DEBUG:     #08 pc 00027137  /system/lib/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+151)
01-06 17:53:46.212 949-949/? A/DEBUG:     #09 pc 00014aac  /system/lib/libutils.so (android::Thread::_threadLoop(void*)+418)
01-06 17:53:46.212 949-949/? A/DEBUG:     #10 pc 0006bfee  /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+98)
01-06 17:53:46.212 949-949/? A/DEBUG:     #11 pc 000141cf  /system/lib/libutils.so (thread_data_t::trampoline(thread_data_t const*)+122)
01-06 17:53:46.212 949-949/? A/DEBUG:     #12 pc 00080a93  /system/lib/libc.so (__pthread_start(void*)+56)
01-06 17:53:46.212 949-949/? A/DEBUG:     #13 pc 00021952  /system/lib/libc.so (__start_thread+25)
01-06 17:53:46.212 949-949/? A/DEBUG:     #14 pc 000170b6  /system/lib/libc.so (__bionic_clone+70)
01-06 17:53:46.282 949-949/? E/DEBUG: AM write failed: Broken pipe
01-06 17:53:46.282 1278-1298/system_process I/BootReceiver: Copying /data/tombstones/tombstone_09 to DropBox (SYSTEM_TOMBSTONE)
01-06 17:53:46.303 1278-8703/system_process W/ActivityManager:   Force finishing activity com.NSouthDomain.NSouthApplication/.Activity_Main
01-06 17:53:46.309 955-955/? I/Zygote: Process 4436 exited due to signal (6)
01-06 17:53:46.319 1278-1320/system_process W/InputDispatcher: channel 'bbdfcc6 com.NSouthDomain.NSouthApplication/com.NSouthDomain.NSouthApplication.Activity_Main (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
01-06 17:53:46.319 1278-1320/system_process E/InputDispatcher: channel 'bbdfcc6 com.NSouthDomain.NSouthApplication/com.NSouthDomain.NSouthApplication.Activity_Main (server)' ~ Channel is unrecoverably broken and will be disposed!
01-06 17:53:46.323 1278-1820/system_process D/GraphicsStats: Buffer count: 3
01-06 17:53:46.391 941-941/? E/EGL_emulation: tid 941: eglCreateSyncKHR(1294): error 0x3004 (EGL_BAD_ATTRIBUTE)
01-06 17:53:46.437 1278-1820/system_process I/WindowState: WIN DEATH: Window{bbdfcc6 u0 com.NSouthDomain.NSouthApplication/com.NSouthDomain.NSouthApplication.Activity_Main}
01-06 17:53:46.437 1278-1820/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel 'bbdfcc6 com.NSouthDomain.NSouthApplication/com.NSouthDomain.NSouthApplication.Activity_Main (server)'
01-06 17:53:46.437 1278-8703/system_process W/ActivityManager: Exception thrown during pause
                                                               android.os.DeadObjectException
                                                                   at android.os.BinderProxy.transactNative(Native Method)
                                                                   at android.os.BinderProxy.transact(Binder.java:503)
                                                                   at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:727)
                                                                   at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:867)
                                                                   at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:2907)
                                                                   at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:2763)
                                                                   at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:2755)
                                                                   at com.android.server.am.ActivityManagerService.handleAppCrashLocked(ActivityManagerService.java:11971)
                                                                   at com.android.server.am.ActivityManagerService.makeAppCrashingLocked(ActivityManagerService.java:11867)
                                                                   at com.android.server.am.ActivityManagerService.crashApplication(ActivityManagerService.java:12556)
                                                                   at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:12063)
                                                                   at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
01-06 17:53:46.441 1278-1290/system_process I/ActivityManager: Process com.NSouthDomain.NSouthApplication (pid 4436) has died
01-06 17:53:46.549 1278-3883/system_process I/OpenGLRenderer: Initialized EGL, version 1.4
01-06 17:53:46.584 1595-1904/com.google.android.googlequicksearchbox W/EGL_emulation: eglSurfaceAttrib not implemented
01-06 17:53:46.584 1595-1904/com.google.android.googlequicksearchbox W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa21efb80, error=EGL_SUCCESS
01-06 17:53:46.607 1278-3883/system_process W/EGL_emulation: eglSurfaceAttrib not implemented
01-06 17:53:46.607 1278-3883/system_process W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9dba5180, error=EGL_SUCCESS
01-06 17:53:47.139 1595-1904/com.google.android.googlequicksearchbox W/OpenGLRenderer: Incorrectly called buildLayer on View: em, destroying layer...
01-06 17:53:47.143 1278-1303/system_process W/WindowAnimator: Failed to dispatch window animation state change.
                                                              android.os.DeadObjectException
                                                                  at android.os.BinderProxy.transactNative(Native Method)
                                                                  at android.os.BinderProxy.transact(Binder.java:503)
                                                                  at android.view.IWindow$Stub$Proxy.onAnimationStopped(IWindow.java:534)
                                                                  at com.android.server.wm.WindowAnimator.updateWindowsLocked(WindowAnimator.java:286)
                                                                  at com.android.server.wm.WindowAnimator.animateLocked(WindowAnimator.java:678)
                                                                  at com.android.server.wm.WindowAnimator.-wrap0(WindowAnimator.java)
                                                                  at com.android.server.wm.WindowAnimator$1.doFrame(WindowAnimator.java:123)
                                                                  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:856)
                                                                  at android.view.Choreographer.doCallbacks(Choreographer.java:670)
                                                                  at android.view.Choreographer.doFrame(Choreographer.java:603)
                                                                  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                  at android.os.Looper.loop(Looper.java:148)
                                                                  at android.os.HandlerThread.run(HandlerThread.java:61)
                                                                  at com.android.server.ServiceThread.run(ServiceThread.java:46)
01-06 17:53:47.172 1278-1293/system_process I/Choreographer: Skipped 32 frames!  The application may be doing too much work on its main thread.
01-06 17:53:47.192 941-941/? W/SurfaceFlinger: couldn't log to binary event log: overflow.

下面是logcat输出。我不知道弃用缓冲区队列 DeadObjectException 意味着什么。从我的研究来看,似乎一个对象是从一个死进程引用的?我不明白为什么会这样,或者为什么这只发生在Marshmallow。任何帮助表示赞赏。谢谢!

"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYW1laWQiOiJjOTFiNjM5MC1iMzYxLTRlNzMtOGM3YS0wODU0M2I1NzNkY2IiLCJ1bmlxdWVfbmFtZSI6IkRlbnlzc2UuZGlhenBvbmNlQG5ic2RlZmF1bHRzZXJ2aWNlcy5jb20iLCJodHRwOi8vc2NoZW1hcy5taWNyb3NvZnQuY29tL2FjY2Vzc2NvbnRyb2xzZXJ2aWNlLzIwMTAvMDcvY2xhaW1zL2lkZW50aXR5cHJvdmlkZXIiOiJBU1AuTkVUIElkZW50aXR5IiwiQXNwTmV0LklkZW50aXR5LlNlY3VyaXR5U3RhbXAiOiIwZjI4ZTZhOS1jMzkyLTQ1OTAtYWVhMS02ZmI5NjBjYzM2ODQiLCJyb2xlIjpbIkJBTXxBZG1pbiIsIkRFTXxNYW5hZ2VyIiwiQkNTfFVzZXIiXSwiZ2l2ZW5fbmFtZSI6IkRlbnlzc2UgRGlheiIsImF2YXRhcklkIjoiNTEiLCJsYXN0TG9naW5EYXRlIjoiMS82LzIwMTYiLCJpc3MiOiJwYWNoaW5rby5pZHNydiIsImF1ZCI6IjIyYjRkYWViYTFmNzRiYTRiOGQyZmNhMzhhY2NjMWMyIiwiZXhwIjoxNDUyMTI0NTM3LCJuYmYiOjE0NTIxMjA5Mzd9.25AuQ54-i_i97BJUHgNdNYStADAz02Y89lZDHk3hiNA",`"token_type": "bearer",`"expires_in": 3599,"refresh_token": "414e30e7-95bb-4a89-b92c-3d3d73c7e605",`"as:client_id": "1",".issued": "Wed, 06 Jan 2016 22:55:37 GMT"`".expires": "Wed, 06 Jan 2016 23:55:37 GMT"`

3 个答案:

答案 0 :(得分:3)

是的,这是M中的一个错误... 但我想出了一个解决方案。 刚做了一个处理程序postDelayed调用~500 ms deplay

答案 1 :(得分:1)

作为评论中的同等对话,您说解雇/取消并不会导致应用程序崩溃,但在此之后还有其他内容。

您的崩溃日志说&gt;&gt;

应用程序可能在其主线程上做了太多工作。

检查您的应用代码并确认您没有在主线程中执行任何长时间运行的任务。

答案 2 :(得分:1)

不是真正的答案,但我找到了解决方法。我没有从Spinner听众那里解雇,而是添加了一个按钮。现在,用户从微调器中选择并点击“#34;应用”。这是一个额外的点击,但至少它的工作原理。由于Apply是默认对话框按钮之一,它会自动关闭对话框,一切都很好。

如果有人知道为什么从Spinner听众的解雇在Marshmallow中断,我全都耳朵。