processing / processing-android

Processing mode and core library to create Android apps with Processing
http://android.processing.org
778 stars 292 forks source link

Fatal signal 11 (SIGSEGV) #201

Closed rich-gg closed 8 years ago

rich-gg commented 8 years ago

Hi

I use Processing in Android Studio the way it is explained here.

When I use

    @Override
    public void settings() {
        fullScreen(P2D);
    }

I often crash and get something like that A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0xa0d03000 in tid 10098 (GLThread 60135)

the thing is:

omerjerk commented 8 years ago

Hi, Which device are you testing your code on ?

rich-gg commented 8 years ago

NVidia Shield K1, Marshmallow

rich-gg commented 8 years ago

If I had, in setup, this test code that I got from Processing sample skteches PGraphicsOpenGL pg = (PGraphicsOpenGL)g; println(PGraphicsOpenGL.OPENGL_VENDOR); println(PGraphicsOpenGL.OPENGL_RENDERER); println(PGraphicsOpenGL.OPENGL_VERSION); println(PGraphicsOpenGL.GLSL_VERSION); println(PGraphicsOpenGL.OPENGL_EXTENSIONS);

First I get the crash: A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0xa1202000 in tid 28868 (GLThread 1159)

Then I comment the "PGraphicsOpenGL pg = (PGraphicsOpenGL)g;" line

and the thing runs ok on my tablet. it shows

04-01 12:11:18.141 24120-24163/gg.rich.droid.myp2d I/System.out: NVIDIA Corporation 04-01 12:11:18.142 24120-24163/gg.rich.droid.myp2d I/System.out: NVIDIA Tegra 04-01 12:11:18.142 24120-24163/gg.rich.droid.myp2d I/System.out: OpenGL ES 3.2 NVIDIA 361.00 04-01 12:11:18.142 24120-24163/gg.rich.droid.myp2d I/System.out: OpenGL ES GLSL ES 3.20 04-01 12:11:18.142 24120-24163/gg.rich.droid.myp2d I/System.out: GL_EXT_debug_marker GL_EXT_base_instance GL_EXT_blend_func_extended GL_EXT_blend_minmax GL_EXT_buffer_storage GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float GL_EXT_copy_image GL_EXT_debug_label GL_EXT_discard_framebuffer GL_EXT_disjoint_timer_query GL_EXT_draw_buffers_indexed GL_EXT_draw_elements_base_vertex GL_EXT_float_blend GL_EXT_frag_depth GL_EXT_geometry_point_size GL_EXT_geometry_shader GL_EXT_gpu_shader5 GL_EXT_map_buffer_range GL_EXT_multi_draw_indirect GL_EXT_multisample_compatibility GL_EXT_occlusion_query_boolean GL_EXT_primitive_bounding_box GL_EXT_render_snorm GL_EXT_robustness GL_EXT_separate_shader_objects GL_EXT_shader_implicit_conversions GL_EXT_shader_integer_mix GL_EXT_shader_io_blocks GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_sparse_texture GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_tessellation_point_size GL_EXT_tessellation_shader GL_EXT_texture_border_clamp GL_EXT_texture_buffer GL_EXT_texture_compression_dxt1 GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map_array GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_norm16 GL_EXT_texture_rg GL_EXT_texture_sRGB_decode GL_EXT_texture_storage GL_EXT_texture_view GL_EXT_unpack_subimage GL_KHR_context_flush_control GL_KHR_debug GL_KHR_no_error GL_KHR_robust_buffer_access_behavior GL_KHR_robustness GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_sliced_3d GL_NV_bgr GL_NV_bindless_texture GL_NV_blend_equation_advanced GL_NV_blend_equation_advanced_coherent GL_NV_conditional_render GL_NV_copy_buffer GL_NV_copy_image GL_NV_draw_buffers GL_NV_draw_instanced GL_NV_draw_texture GL_NV_EGL_stream_consumer_external GL_NV_explicit_attrib_location GL_NV_fbo_color_attachments GL_NV_framebuffer_blit GL_NV_framebuffer_multisample GL_NV_generate_mipmap_sRGB GL_NV_instanced_arrays GL_NV_internalformat_sample_query GL_NV_gpu_shader5 GL_NV_image_formats GL_NV_occlusion_query_samples GL_NV_non_square_matrices GL_NV_pack_subimage GL_NV_packed_float GL_NV_packed_float_linear GL_NV_path_rendering GL_NV_pixel_buffer_object GL_NV_polygon_mode GL_NV_read_buffer GL_NV_read_depth GL_NV_read_depth_stencil GL_NV_read_stencil GL_NV_secure_context GL_NV_shader_noperspective_interpolation GL_NV_shadow_samplers_array GL_NV_shadow_samplers_cube GL_NV_sRGB_formats GL_NV_texture_array GL_NV_texture_border_clamp GL_NV_texture_compression_latc GL_NV_texture_compression_s3tc GL_NV_texture_compression_s3tc_update GL_NV_timer_query GL_NV_viewport_array GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth24 GL_OES_depth32 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_copy_image GL_OES_draw_buffers_indexed GL_OES_draw_elements_base_vertex GL_OES_texture_border_clamp GL_OES_tessellation_point_size GL_OES_tessellation_shader GL_OES_texture_buffer GL_OES_geometry_point_size GL_OES_geometry_shader GL_OES_gpu_shader5 GL_OES_shader_io_blocks GL_OES_texture_view GL_OES_primitive_bounding_box GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_get_program_binary GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_sample_shading GL_OES_sample_variables GL_OES_shader_image_atomic GL_OES_shader_multisample_interpolation GL_OES_standard_derivatives GL_OES_surfaceless_context GL_OES_texture_cube_map_array GL_OES_texture_npot GL_OES_texture_float GL_OES_texture_float_linear GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_stencil8 GL_OES_texture_storage_multisample_2d_array GL_OES_vertex_array_object GL_OES_vertex_half_float GL_ANDROID_extension_pack_es31a

but if I remove the comments on that same line, it works just fine !

I tried many times to reproduce the problem but I succeeded only once, so that is chance

rich-gg commented 8 years ago

same problem occurs with Sony Xperia Z1 compact Lollipop

rich-gg commented 8 years ago

I might have a clue: the crash usually happens right after launch but right before the screen size is "settled"

I can see that the canvas resolution doesn't start neatly. When launching the app, the sequences somehow goes like this: -1- black screen -2- screen get of background colour (in my case white), but only fills 4 fifth of height, starting from top -3- SOMETIMES, crash with "Fatal signal 11 (SIGSEGV)" error, sometime not -4- screen display processing sketch properly, full-screen.

Thing is, I've printed println(width + " | " + height); println( displayWidth + " | " + displayHeight);

at various stages of the sketch, and the resolution doesn't settle right away. for instance, on my K1:

in settings() System.out: 1920 | 1104 System.out: 1920 | 1104

at the beginning of setup() System.out: 1920 | 928 System.out: 1920 | 1104

at the end of setup() System.out: 1920 | 928 System.out: 1920 | 1104

once in draw() System.out: 1920 | 1200 System.out: 1920 | 1104

"Fatal signal 11 (SIGSEGV)" crash occurs after the last line of setup() and before first line of draw is executed

+, for info, the manifest for my app uses IMMERSION mode like so: decorView.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);}

rich-gg commented 8 years ago

didn't get over the bug, today it looks like this A/libc: Fatal signal 11 (SIGSEGV), code 2, fault addr 0xa09a1000 in tid 11767 (GLThread 890)

but I got a little further in understanding the tricky business with width and height. Apparently, in Android you are not supposed to mess around with the actual pixel size of your display since the system is supposed to "take it from here" http://radar.oreilly.com/2013/06/four-simple-rules-to-avoid-displaymetrics-antipatterns-in-android-code.html

but, as I am not dealing with layout and stuff, I think I want to have pixel sizes I can rely on.

I can get them using this:

    DisplayMetrics dm = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getRealMetrics(dm);
    rWidth = dm.widthPixels;
    rHeight = dm.heightPixels;
    println("rWidth " + rWidth + " | rHeight " + rHeight);

to whom ever it may seem useful

codeanticode commented 8 years ago

@rich-gg thanks for bringing up the potential issue with the use DisplayMetric. I will look into ways of handling it better.

rich-gg commented 8 years ago

@codeanticode anything you could tell me about the OpenGL crashes ?

codeanticode commented 8 years ago

I tried to reproduce it, but was not able to.

rich-gg commented 8 years ago

neither am I. I mean I'm down to try stupid things like putting my android device in menu mode, or having an app opened before I launch my app from Android Studio. And sometimes it works ! So I don't even know if it will happen anytime I launch the app.

I though maybe the error message itself would mean something to an OpenGL guy

Going to try to put this in manifest android:hardwareAccelerated="true"

like it is suggested here why not ?

codeanticode commented 8 years ago

I don't think hardwareAccelerated=true will make a difference, as it is probably the default, specially when using the GL renderers.

However, your earlier comments about the with/height not being properly set during setup might be pointing to something. Looking into it.

codeanticode commented 8 years ago

I did some changes in the way the sketch's size variables are set: https://github.com/processing/processing-android/commit/6ae45c9d90e0766ae4d82b18178767937989d43e

It is working fine on my development device, will be available in RC3 for you to test.

rich-gg commented 8 years ago

cool :)

you don't use getRealMetrics()...

In my Sketch_Activity.java I have

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);

        View decorView = getWindow().getDecorView();
        if (hasFocus) {
            decorView.setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                            | View.SYSTEM_UI_FLAG_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);}   
    }

will I have to remove some of those flags with the new code ?

codeanticode commented 8 years ago

Please try RC3, and let me know if you still see these crashes.

rich-gg commented 8 years ago

going to spend the week using it.

rich-gg commented 8 years ago

Since RC3, my apps run flawlessly on both my Z1 compact Lollipop and my K1 shield Marshmallow

:+1:

codeanticode commented 8 years ago

Great, thanks for the update.