Crash when rendering graphics with Swiftshader on Android

340 views
Skip to first unread message

Irena Pasvinter

unread,
Feb 6, 2022, 2:47:37 PM2/6/22
to swiftshader
Hello,

When we use Swiftshader which is part of the Android image (compiled for ARM64) to render graphics, Android12 boot sometimes crashes in JIT code.

The crash occurs in access to Texture’s data.
 
As we analized the crash, we found the following:

A texture with an external format FORMAT_A16B16G16R16F was created from an
Android native buffer (HAL_PIXEL_FORMAT_RGBA_FP16 -> GL_RGBA16F).

All textures with half float (2 bytes) external formats are constructed with the corresponding single float precision (4 bytes) internal format (FORMAT_A32B32G32R32F).

When applyTexture is called, it calls Sampler::setTextureLevel that calls
surface->lockInternal(…). This virtual function is overridden in AndroidNativeImage class
(swiftshader/src/OpenGL/common/Image.hpp), and it returns the pointer to a native buffer that has “half float” data.

When a shader code containing access to texture data is generated, it calculates offset in the buffer using four-float-per-texel (FORMAT_A32B32G32R32F, 16 bytes ). This often causes crashes because the calculated offset is incorrect.
 
From tombstone:
pid: 379, tid: 435, name: RenderEngine  >>> /system/bin/surfaceflinger <<<
uid: 1000
signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x774823f010
    x0  000000000003c010  x1  0000000000003c80  x2  0000000000003c81  x3  000000
000003c000
    x4  0000000000000008  x5  0000000000000004  x6  2e7265646168732e  x7  6e6962
2e72656461
    x8  0000000000019ee0  x9  00000000000018b0  x10 00000000000018b2  x11 000000
74b166e638
    x12 0000000000000002  x13 0000000000000004  x14 0000000000000008  x15 000000
00000184b0
    x16 0000000000019f20  x17 00000000000098c0  x18 0000007748203000  x19 000000
7553e473d0
    x20 00000074b166f370  x21 0000000000000004  x22 0000007653979108  x23 000000
74b1672000
    x24 0000000000000001  x25 0000000000000004  x26 00000075e397e060  x27 000000
60b48ce000
    x28 00000075e397e010  x29 00000074b166e7c0
    lr  00000074ab6dd490  sp  00000074b166e430  pc  00000077485573b4  pst 000000
0000001000
 
backtrace:
      #00 pc 00000000000003b4  [anon:swiftshader_jit]
      #01 pc 000000000097f48c  /vendor/lib64/egl/libGLESv2_swiftshader.so (sw::Renderer::executeTask(int)+1248) (BuildId: a5771f173a7615706148282b349cf3a6)
      #02 pc 000000000097e95c  /vendor/lib64/egl/libGLESv2_swiftshader.so (sw::Renderer::taskLoop(int)+88) (BuildId: a5771f173a7615706148282b349cf3a6)
      #03 pc 000000000097d53c  /vendor/lib64/egl/libGLESv2_swiftshader.so (sw::Renderer::draw(sw::DrawType, unsigned int, unsigned int, bool)+8972) (BuildId: a5771f173a7615706148282b349cf3a6)
      #04 pc 000000000088dcd4  /vendor/lib64/egl/libGLESv2_swiftshader.so (es2::Device::drawPrimitive(sw::DrawType, unsigned int)+88) (BuildId: a5771f173a7615706148282b349cf3a6)
……
……
 
Do you have any advice/suggestions on how to fix this crash?

Thank you,
Irena

Nicolas Capens

unread,
Feb 6, 2022, 9:35:23 PM2/6/22
to Irena Pasvinter, swiftshader
Hi Irena,

This is a crash in SwiftShader's legacy OpenGL ES implementation, which we're no longer maintaining. Which board config is this Android 12 image using?

Regards,
Nicolas

--
You received this message because you are subscribed to the Google Groups "swiftshader" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swiftshader...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/swiftshader/3ee0ff09-843c-454e-ae9e-1c797451ca95n%40googlegroups.com.

Irena Pasvinter

unread,
Feb 7, 2022, 4:17:16 AM2/7/22
to swiftshader
Hi Nicolas,

We use ranchu board config, with additional modifications: we replace *emulation libraries with *swiftshader libraries and set properties ro.hardware.gralloc=default, ro.hardware.vulkan=pastel. We also make corresponding changes in vendor.mk and manifest to adjust versions of graphics composer and allocator packages.

This combination worked for us in Android 11 without crashes. Probably we didn't encounter a half-float texture there.

Regards,
Irena

Nicolas Capens

unread,
Feb 7, 2022, 6:39:01 PM2/7/22
to Irena Pasvinter, Bo Hu, Yiwei Zhang, swiftshader, Jason Macnak
Thanks for the info. I've CC'd a few people who might be able to help out.

Reply all
Reply to author
Forward
0 new messages