我参考了grafika的ContinuousCaptureActivity来实现一个使用MediaCodec录制视频的demo。演示在大多数情况下运行良好,但在我的 GT-I9500 设备上按下后退键时崩溃(此崩溃无法检测,因为我们只是假设活动被破坏,我使用“adb shell ps”来检查演示进程的存在)。然后我反复检查我的源代码,发现我的代码和grafika的ContinuousCaptureActivity几乎一样。所以我做了以下事情:
我在我的GT-I9500设备上安装了grafika的apk并启动了ContinuousCaptureActivity,然后我按了手机的返回键,但应用程序没有崩溃,结果grafika运行良好。
我再次检查了我的代码,没有发现任何可疑之处。
我创建了一个新的 android 项目,并将 ContinuousCaptureActivity.java 和其他必要的文件(如 AndroidManifest.xml、activity_continuous_capture.xml 等)从 grafika 复制到新项目中。我修改了 AndroidManifest.xml 以使 ContinuousCaptureActivity 成为主要活动。我编译了代码并在我的 GT-I9500 设备上安装了 apk。同样的事情发生了,我按下后退键后应用程序崩溃了!!!
我真的对这个问题感到困惑,为什么 grafika 工作正常但新项目中的相同代码却崩溃了?无论如何,我相信我的演示崩溃有一个解决方案,因为 grafika 工作得很好。有人可以给我一些建议吗?
我可以提供的信息如下:
我调试了应用程序并找到了导致崩溃的确切代码,代码是https://github.com/google/grafika/blob/master/src/com/android/grafika/gles/EglCore.java#L191
崩溃非常惨烈,没有生成墓碑文件,并且 adb 日志受到限制:
06-15 14:39:33.853 I/ActivityManager(771): 进程 com.example.grafikaaa (pid 13138) (adj 1) 已经死亡。
06-15 14:39:33.853 W/ActivityManager(771):强制删除 ActivityRecord{42a876c8 u0 com.example.grafikaaa/.ContinuousCaptureActivity}:应用程序死亡,没有保存状态......
06-15 14:39:33.903 D/Zygote (209): 进程 13138 由信号 (11) 终止
- grafika 的 GlesInfoActivity 显示的我的设备信息如下:
===== GL Information ===== vendor : Qualcomm version : OpenGL ES 3.0 V@45.0 AU@ (CL@4169980) renderer : Adreno (TM) 320 extensions: GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_AMD_program_binary_Z400 GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_disjoint_timer_query GL_EXT_robustness GL_EXT_sRGB GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV GL_NV_fence GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high GL_OES_get_program_binary GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_array_object GL_OES_vertex_half_float GL_OES_vertex_type_10_10_10_2 GL_QCOM_alpha_test GL_QCOM_binning_control GL_QCOM_driver_control GL_QCOM_extended_get GL_QCOM_extended_get2 GL_QCOM_perfmon_global_mode GL_QCOM_tiled_rendering GL_QCOM_writeonly_rendering ===== EGL Information ===== vendor : Android version : 1.4 Android META-EGL client API: OpenGL_ES extensions: EGL_ANDROID_image_native_buffer EGL_EXT_create_context_robustness EGL_KHR_create_context EGL_KHR_fence_sync EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_image EGL_KHR_image_base EGL_KHR_lock_surface EGL_KHR_wait_sync ===== System Information ===== mfgr : samsung brand : samsung model : GT-I9500 release : 4.3 build : JSS15J.I9500ZSUEMJ6