Open frankcjw opened 6 months ago
Hi,
It is indeed an OpenGL issue. I am not familiar with OpenGL, so I won't be able to help a lot. I guess the fact that you don't use a real Android phone might be a problem (missing features?).
E/ion ( 6991): ioctl c0044901 failed with code -1: Inappropriate ioctl for device
E/.zhenyi.app.bo( 6991): error creating EGLImage: 0x3003
E/.zhenyi.app.bo( 6991): Failed to create image. size=15x12 st=15 usage=0x20 fmt=1
W/.zhenyi.app.bo( 6991): [SurfaceTexture-1-6991-1] bindTextureImage: can't create image on display=0x1 slot=-1
These are inside Android framework. 0x3003 is EGL_BAD_ALLOC. From what I read, I could happen if a lot of GLContext have been opened and not closed.
Hi,
It is indeed an OpenGL issue. I am not familiar with OpenGL, so I won't be able to help a lot. I guess the fact that you don't use a real Android phone might be a problem (missing features?).
E/ion ( 6991): ioctl c0044901 failed with code -1: Inappropriate ioctl for device E/.zhenyi.app.bo( 6991): error creating EGLImage: 0x3003 E/.zhenyi.app.bo( 6991): Failed to create image. size=15x12 st=15 usage=0x20 fmt=1 W/.zhenyi.app.bo( 6991): [SurfaceTexture-1-6991-1] bindTextureImage: can't create image on display=0x1 slot=-1
These are inside Android framework. 0x3003 is EGL_BAD_ALLOC. From what I read, I could happen if a lot of GLContext have been opened and not closed.
It's a real android device . I just ran the demo and nothing changed.
It's seems something ran wrong with OpenGL or SurfaceTexture
When did this happen? When calling startStream
, startPreview
,...?
startStream
When call startStream
. Then crashed
05-06 19:42:40.495 6288 6350 D CCodecBuffers: [c2.android.aac.encoder#189:Output[N]] popFromStashAndRegister: output format changed to AMessage(what = 0x00000000) = {
05-06 19:42:40.495 6288 6350 D CCodecBuffers: int32_t aac-sbr-mode = 3
05-06 19:42:40.495 6288 6350 D CCodecBuffers: int32_t bitrate = 128000
05-06 19:42:40.495 6288 6350 D CCodecBuffers: int32_t channel-count = 2
05-06 19:42:40.495 6288 6350 D CCodecBuffers: int32_t level = 0
05-06 19:42:40.495 6288 6350 D CCodecBuffers: int32_t max-bitrate = 128000
05-06 19:42:40.495 6288 6350 D CCodecBuffers: string mime = "audio/mp4a-latm"
05-06 19:42:40.495 6288 6350 D CCodecBuffers: int32_t profile = 2
05-06 19:42:40.495 6288 6350 D CCodecBuffers: int32_t sample-rate = 44100
05-06 19:42:40.495 6288 6350 D CCodecBuffers: Buffer csd-0 = {
05-06 19:42:40.495 6288 6350 D CCodecBuffers: 00000000: 12 10 ..
05-06 19:42:40.495 6288 6350 D CCodecBuffers: }
05-06 19:42:40.495 6288 6350 D CCodecBuffers: }
05-06 19:42:40.497 371 6344 E omx_venc: omx decoder info : author: zts
05-06 19:42:40.497 371 6344 E omx_venc: time: git commit d6abf16bcef430920d10e596d569c244f9dc05ad
05-06 19:42:40.497 371 6344 E omx_venc: open vpu context new
05-06 19:42:40.497 371 6344 I mpp_info: mpp version: 02f9321b author: Chen Jinsen 2021-08-27 add local_diff_base_1c2c12.patch
05-06 19:42:40.497 371 6344 I omx_venc: use mpp.
05-06 19:42:40.497 371 6344 E omx_venc: ConvertOmxAvcLevelToAvcSpecLevel: 32768
05-06 19:42:40.497 371 6344 I omx_venc: encode params init settings:
05-06 19:42:40.497 371 6344 I omx_venc: width = 1280
05-06 19:42:40.497 371 6344 I omx_venc: height = 720
05-06 19:42:40.497 371 6344 I omx_venc: bitRate = 2000000
05-06 19:42:40.497 371 6344 I omx_venc: framerate = 30
05-06 19:42:40.497 371 6344 I omx_venc: format = 10
05-06 19:42:40.497 371 6344 I omx_venc: enableCabac = 0,
05-06 19:42:40.497 371 6344 I omx_venc: cabacInitIdc = 0,
05-06 19:42:40.497 371 6344 I omx_venc: intraPicRate = 29,
05-06 19:42:40.497 371 6344 I omx_venc: profileIdc = 100,
05-06 19:42:40.497 371 6344 I omx_venc: levelIdc = 51,
05-06 19:42:40.497 371 6344 I omx_venc: rc_mode = 1,
05-06 19:42:40.497 371 6344 I omx_venc:
05-06 19:42:40.498 362 362 W ResourceManagerService: Ignoring request to add new resource entry with value <= 0
05-06 19:42:40.499 371 6344 I vpu_api_legacy: setup encoder rate control config:
05-06 19:42:40.499 371 6344 I vpu_api_legacy: width 1280 height 720 format 10:1000d
05-06 19:42:40.499 371 6344 I vpu_api_legacy: rc_mode CBR qp 26 bps 2000000
05-06 19:42:40.499 371 6344 I vpu_api_legacy: fps in 30 fps out 30 gop 29
05-06 19:42:40.499 371 6344 I vpu_api_legacy: setup encoder stream feature config:
05-06 19:42:40.499 371 6344 I vpu_api_legacy: profile 100 level 51 cabac 0
05-06 19:42:40.499 371 6370 I mpp_enc : MPP_ENC_SET_RC_CFG bps 2000000 [1875000 : 2125000] fps [30:30] gop 29
05-06 19:42:40.499 371 6370 I h264e_api_v2: MPP_ENC_SET_PREP_CFG w:h [1280:720] stride [5120:720]
05-06 19:42:40.499 371 6370 I mpp_enc : send header for set cfg change input/format
05-06 19:42:40.503 371 6370 I mpp_enc : mode cbr bps [1875000:2000000:2125000] fps fix [30/1] -> fix [30/1] gop i [29] v [0]
05-06 19:42:40.504 371 6344 I vpu_api_legacy: setup encoder rate control config:
05-06 19:42:40.504 371 6344 I vpu_api_legacy: width 1280 height 720 format 10:1000d
05-06 19:42:40.504 371 6344 I vpu_api_legacy: rc_mode CBR qp 26 bps 2000000
05-06 19:42:40.504 371 6344 I vpu_api_legacy: fps in 30 fps out 30 gop 29
05-06 19:42:40.504 371 6344 I vpu_api_legacy: setup encoder stream feature config:
05-06 19:42:40.504 371 6344 I vpu_api_legacy: profile 100 level 51 cabac 0
05-06 19:42:40.505 6288 6288 I NDOP : listening using window listener
05-06 19:42:40.506 371 6370 I mpp_enc : send header for set cfg change codec
05-06 19:42:40.512 378 6354 I C2SoftAacEnc: Correcting overlapping timestamp: last frame ended at 35851745216us but current frame is starting at 35851745027us. Using the last frame's end timestamp
05-06 19:42:40.516 239 239 D gralloc4: [File] : hardware/rockchip/libgralloc/bifrost/src/hidl_common/Allocator.cpp; [Line] : 149; [Func] : allocate;
05-06 19:42:40.516 239 239 D gralloc4: got new private_handle_t instance @0xb4000078a7f92770 for buffer 'SurfaceTexture-1-6288-1'. share_fd : 6, share_attr_fd : 9, flags : 0x4, width : 1280, height : 720, req_format : 0x22, producer_usage : 0x60030133, consumer_usage : 0x60030133, internal_format : 0x0, stride : 1280, byte_stride : 0, internalWidth : 0, internalHeight : 0, alloc_format : 0x100, size : 1843200, layer_count : 1, backing_store_size : 1843200, backing_store_id : 1026497184368, allocating_pid : 239, ref_count : 1, yuv_info : 3
05-06 19:42:40.516 239 239 D gralloc4: plane_info[0]: offset : 0, byte_stride : 1280, alloc_width : 1280, alloc_height : 720
05-06 19:42:40.516 239 239 D gralloc4: plane_info[1]: offset : 921600, byte_stride : 1280, alloc_width : 640, alloc_height : 360
05-06 19:42:40.517 371 6368 I omx_venc: set bSpsPpsLen 39
05-06 19:42:40.522 371 3337 E OMXNodeInstance: getConfig(0xeb1c1740:rk._encoder.avc, ConfigAndroidIntraRefresh(0x6f60000a)) ERROR: UnsupportedIndex(0x8000101a)
05-06 19:42:40.525 6288 6346 I MediaCodecEncoder: Format changed : {max-bitrate=2000000, csd-1=java.nio.HeapByteBuffer[pos=0 lim=9 cap=9], color-transfer=3, mime=video/avc, width=1280, bitrate=2000000, color-range=2, frame-rate=30, color-standard=1, height=720, csd-0=java.nio.HeapByteBuffer[pos=0 lim=30 cap=30]}
05-06 19:42:40.534 239 239 D gralloc4: [File] : hardware/rockchip/libgralloc/bifrost/src/hidl_common/Allocator.cpp; [Line] : 149; [Func] : allocate;
05-06 19:42:40.534 239 239 D gralloc4: got new private_handle_t instance @0xb4000078a7f92530 for buffer 'GraphicBufferSource'. share_fd : 6, share_attr_fd : 9, flags : 0x4, width : 1280, height : 720, req_format : 0x23, producer_usage : 0x10200, consumer_usage : 0x10200, internal_format : 0x0, stride : 0, byte_stride : 0, internalWidth : 0, internalHeight : 0, alloc_format : 0x100, size : 1382400, layer_count : 1, backing_store_size : 1382400, backing_store_id : 1026497184369, allocating_pid : 239, ref_count : 1, yuv_info : 3
05-06 19:42:40.535 239 239 D gralloc4: plane_info[0]: offset : 0, byte_stride : 1280, alloc_width : 1280, alloc_height : 720
05-06 19:42:40.535 239 239 D gralloc4: plane_info[1]: offset : 921600, byte_stride : 1280, alloc_width : 640, alloc_height : 360
05-06 19:42:40.545 6288 6318 I flutter : Connection succeeded
05-06 19:42:40.550 239 239 D gralloc4: [File] : hardware/rockchip/libgralloc/bifrost/src/hidl_common/Allocator.cpp; [Line] : 149; [Func] : allocate;
05-06 19:42:40.550 239 239 D gralloc4: got new private_handle_t instance @0xb4000078a7f92770 for buffer '[EGLConsumer debug texture]'. share_fd : 6, share_attr_fd : 9, flags : 0x4, width : 15, height : 12, req_format : 0x1, producer_usage : 0x20, consumer_usage : 0x20, internal_format : 0x0, stride : 15, byte_stride : 0, internalWidth : 0, internalHeight : 0, alloc_format : 0x1, size : 720, layer_count : 1, backing_store_size : 720, backing_store_id : 1026497184370, allocating_pid : 239, ref_count : 1, yuv_info : 0
05-06 19:42:40.550 239 239 D gralloc4: plane_info[0]: offset : 0, byte_stride : 60, alloc_width : 15, alloc_height : 12
05-06 19:42:40.551 239 239 D gralloc4: plane_info[1]: offset : 0, byte_stride : 0, alloc_width : 0, alloc_height : 0
05-06 19:42:40.551 6288 6337 E ion : ioctl c0044901 failed with code -1: Inappropriate ioctl for device
05-06 19:42:40.551 6288 6337 E .zhenyi.app.bo: error creating EGLImage: 0x3003
05-06 19:42:40.552 6288 6337 E .zhenyi.app.bo: Failed to create image. size=15x12 st=15 usage=0x20 fmt=1
05-06 19:42:40.552 6288 6337 W .zhenyi.app.bo: [SurfaceTexture-1-6288-1] bindTextureImage: can't create image on display=0x1 slot=-1
--------- beginning of crash
05-06 19:42:40.555 6288 6337 E AndroidRuntime: FATAL EXCEPTION: pool-4-thread-1
05-06 19:42:40.555 6288 6337 E AndroidRuntime: Process: com.zhenyi.app.bom, PID: 6288
05-06 19:42:40.555 6288 6337 E AndroidRuntime: java.lang.RuntimeException: Error during updateTexImage (see logcat for details)
05-06 19:42:40.555 6288 6337 E AndroidRuntime: at android.graphics.SurfaceTexture.nativeReleaseTexImage(Native Method)
05-06 19:42:40.555 6288 6337 E AndroidRuntime: at android.graphics.SurfaceTexture.releaseTexImage(SurfaceTexture.java:258)
05-06 19:42:40.555 6288 6337 E AndroidRuntime: at io.github.thibaultbee.streampack.internal.encoders.VideoMediaCodecEncoder$CodecSurface.onFrameAvailable$lambda$9(VideoMediaCodecEncoder.kt:263)
05-06 19:42:40.555 6288 6337 E AndroidRuntime: at io.github.thibaultbee.streampack.internal.encoders.VideoMediaCodecEncoder$CodecSurface.$r8$lambda$beCZ0tKmLlcQAOcowgyTvNzP_wI(Unknown Source:0)
05-06 19:42:40.555 6288 6337 E AndroidRuntime: at io.github.thibaultbee.streampack.internal.encoders.VideoMediaCodecEncoder$CodecSurface$$ExternalSyntheticLambda2.run(Unknown Source:4)
05-06 19:42:40.555 6288 6337 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
05-06 19:42:40.555 6288 6337 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
05-06 19:42:40.555 6288 6337 E AndroidRuntime: at java.lang.Thread.run(Thread.java:923)
05-06 19:42:40.558 439 3640 D WifiNl80211Manager: Scan result ready event
05-06 19:42:40.558 439 3640 D WifiNative: Scan result ready event
05-06 19:42:40.559 371 6369 E omx_venc: aPhy_address = 0x0000003f
05-06 19:42:40.559 371 6370 I mpp_enc : send header for codec/prep cfg change
05-06 19:42:40.559 371 6369 I vpu_api_legacy: setup encoder rate control config:
05-06 19:42:40.559 371 6369 I vpu_api_legacy: width 1280 height 720 format 10:0
05-06 19:42:40.559 371 6369 I vpu_api_legacy: rc_mode CBR qp 26 bps 2000000
05-06 19:42:40.559 371 6369 I vpu_api_legacy: fps in 30 fps out 30 gop 29
05-06 19:42:40.559 371 6369 I vpu_api_legacy: setup encoder stream feature config:
05-06 19:42:40.559 371 6369 I vpu_api_legacy: profile 100 level 51 cabac 0
05-06 19:42:40.560 371 6370 I h264e_api_v2: MPP_ENC_SET_PREP_CFG w:h [1280:720] stride [1280:720]
05-06 19:42:40.560 371 6370 I mpp_enc : send header for set cfg change input/format
05-06 19:42:40.560 371 6370 I mpp_enc : mode cbr bps [1875000:2000000:2125000] fps fix [30/1] -> fix [30/1] gop i [29] v [0]
05-06 19:42:40.566 6288 6372 E libEGL : eglMakeCurrentImpl:1100 error 3002 (EGL_BAD_ACCESS)
05-06 19:42:40.568 6288 6372 I Process : Sending signal. PID: 6288 SIG: 9
here is the crash log crash.log
05-06 19:42:40.545 6288 6318 I flutter : Connection succeeded
05-06 19:42:40.550 239 239 D gralloc4: [File] : hardware/rockchip/libgralloc/bifrost/src/hidl_common/Allocator.cpp; [Line] : 149; [Func] : allocate;
05-06 19:42:40.550 239 239 D gralloc4: got new private_handle_t instance @0xb4000078a7f92770 for buffer '[EGLConsumer debug texture]'. share_fd : 6, share_attr_fd : 9, flags : 0x4, width : 15, height : 12, req_format : 0x1, producer_usage : 0x20, consumer_usage : 0x20, internal_format : 0x0, stride : 15, byte_stride : 0, internalWidth : 0, internalHeight : 0, alloc_format : 0x1, size : 720, layer_count : 1, backing_store_size : 720, backing_store_id : 1026497184370, allocating_pid : 239, ref_count : 1, yuv_info : 0
05-06 19:42:40.550 239 239 D gralloc4: plane_info[0]: offset : 0, byte_stride : 60, alloc_width : 15, alloc_height : 12
05-06 19:42:40.551 239 239 D gralloc4: plane_info[1]: offset : 0, byte_stride : 0, alloc_width : 0, alloc_height : 0
05-06 19:42:40.551 6288 6337 E ion : ioctl c0044901 failed with code -1: Inappropriate ioctl for device
05-06 19:42:40.551 6288 6337 E .zhenyi.app.bo: error creating EGLImage: 0x3003
05-06 19:42:40.552 6288 6337 E .zhenyi.app.bo: Failed to create image. size=15x12 st=15 usage=0x20 fmt=1
05-06 19:42:40.552 6288 6337 W .zhenyi.app.bo: [SurfaceTexture-1-6288-1] bindTextureImage: can't create image on display=0x1 slot=-1
Not sure if it is related but the resolution changed (15x12) just after the connection success event. I don't see a reason why. But it is internal to Android and not to this library.
I tested your code with my Pixel 4a and it worked as expected. So, It seems to be a device related issue.
If you are interesting of having a closer look to the OpenGL/SurfaceTexture part, you can have a look here and here. The code really needs some love but it works till now 🤷
05-06 19:42:40.545 6288 6318 I flutter : Connection succeeded 05-06 19:42:40.550 239 239 D gralloc4: [File] : hardware/rockchip/libgralloc/bifrost/src/hidl_common/Allocator.cpp; [Line] : 149; [Func] : allocate; 05-06 19:42:40.550 239 239 D gralloc4: got new private_handle_t instance @0xb4000078a7f92770 for buffer '[EGLConsumer debug texture]'. share_fd : 6, share_attr_fd : 9, flags : 0x4, width : 15, height : 12, req_format : 0x1, producer_usage : 0x20, consumer_usage : 0x20, internal_format : 0x0, stride : 15, byte_stride : 0, internalWidth : 0, internalHeight : 0, alloc_format : 0x1, size : 720, layer_count : 1, backing_store_size : 720, backing_store_id : 1026497184370, allocating_pid : 239, ref_count : 1, yuv_info : 0 05-06 19:42:40.550 239 239 D gralloc4: plane_info[0]: offset : 0, byte_stride : 60, alloc_width : 15, alloc_height : 12 05-06 19:42:40.551 239 239 D gralloc4: plane_info[1]: offset : 0, byte_stride : 0, alloc_width : 0, alloc_height : 0 05-06 19:42:40.551 6288 6337 E ion : ioctl c0044901 failed with code -1: Inappropriate ioctl for device 05-06 19:42:40.551 6288 6337 E .zhenyi.app.bo: error creating EGLImage: 0x3003 05-06 19:42:40.552 6288 6337 E .zhenyi.app.bo: Failed to create image. size=15x12 st=15 usage=0x20 fmt=1 05-06 19:42:40.552 6288 6337 W .zhenyi.app.bo: [SurfaceTexture-1-6288-1] bindTextureImage: can't create image on display=0x1 slot=-1
Not sure if it is related but the resolution changed (15x12) just after the connection success event. I don't see a reason why. But it is internal to Android and not to this library.
I tested your code with my Pixel 4a and it worked as expected. So, It seems to be a device related issue.
If you are interesting of having a closer look to the OpenGL/SurfaceTexture part, you can have a look here and here. The code really needs some love but it works till now 🤷
Thanks a lot. This demo works fine on my phone too. It seems to only crash on that device. T.T
Version
v1.2.0
Which operating systems have you used?
Environment that reproduces the issue
not on a normal android phone.
Is it reproducible in the example application?
Yes
RTMP Server
selfhost rtmp server[worked]
Reproduction steps
I'm try to run the demo on this device but crash.
It's looks like something wrong whit openGL settings
Expected result
streaming succesfully
Actual result
crash immediately
Additional context
Flutter (Channel stable, 3.19.3, on macOS 14.1.1 23B81 darwin-arm64, locale en-CN) Android SDK version 32.0.0
device android version: android 11
Relevant logs output