Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Crah on some android device #54

Open
1 of 2 tasks
frankcjw opened this issue May 4, 2024 · 6 comments
Open
1 of 2 tasks

[Bug]: Crah on some android device #54

frankcjw opened this issue May 4, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@frankcjw
Copy link

frankcjw commented May 4, 2024

Version

v1.2.0

Which operating systems have you used?

  • Android
  • iOS

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.


class LiveViewPage extends StatefulWidget {
  const LiveViewPage({Key? key}) : super(key: key);

  @override
  _LiveViewPageState createState() => new _LiveViewPageState();
}

class _LiveViewPageState extends State<LiveViewPage>
    with WidgetsBindingObserver {
  var rtmp = 'rtmp://192.168.50.111:1935/stream/';
  var rtmpKey = 'mm';

  final ButtonStyle buttonStyle =
      ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20));

  // Params config = Params();
  late final ApiVideoLiveStreamController _controller;
  bool _isStreaming = false;

  @override
  void initState() {
    // WidgetsBinding.instance.addObserver(this);

    _controller = createLiveStreamController();
    _controller.setIsMuted(true);
    _controller.initialize().catchError((e) {
      showInSnackBar(e.toString());
    });
    // _controller.stopPreview();
    super.initState();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    // App state changed before we got the chance to initialize.
    // if (!_controller.isInitialized) {
    //   return;
    // }
    //
    // if (state == AppLifecycleState.inactive) {
    //   _controller.stop();
    // } else if (state == AppLifecycleState.resumed) {
    //   _controller.startPreview();
    // }
  }

  ApiVideoLiveStreamController createLiveStreamController() {
    return ApiVideoLiveStreamController(
        initialAudioConfig: AudioConfig(),
        initialVideoConfig: VideoConfig.withDefaultBitrate(),
        onConnectionSuccess: () {
          print('Connection succeeded');
        },
        onConnectionFailed: (error) {
          print('Connection failed: $error');
          _showDialog(context, 'Connection failed', '$error');
          if (mounted) {
            setIsStreaming(false);
          }
        },
        onDisconnection: () {
          showInSnackBar('Disconnected');
          if (mounted) {
            setIsStreaming(false);
          }
        },
        onError: (error) {
          // Get error such as missing permission,...
          _showDialog(context, 'Error', '$error');
          if (mounted) {
            setIsStreaming(false);
          }
        });
  }

  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        key: _scaffoldKey,
        appBar: AppBar(
          title: Text('[$_isStreaming]abc $count'),
          actions: <Widget>[
            // PopupMenuButton<String>(
            //   onSelected: (choice) => _onMenuSelected(choice, context),
            //   itemBuilder: (BuildContext context) {
            //     return Constants.choices.map((String choice) {
            //       return PopupMenuItem<String>(
            //         value: choice,
            //         child: Text(choice),
            //       );
            //     }).toList();
            //   },
            // )
          ],
        ),
        body: SafeArea(
          child: Center(
            child: Column(
              children: <Widget>[
                Text('$rtmp $rtmpKey'),
                _controlRowWidget(),
                Expanded(
                  child: Container(
                    child: Padding(
                      padding: const EdgeInsets.all(1.0),
                      child: Center(
                        child: ApiVideoCameraPreview(controller: _controller),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ));
  }

  void _onMenuSelected(String choice, BuildContext context) {
    // if (choice == Constants.Settings) {
    //   _awaitResultFromSettingsFinal(context);
    // }
  }

  // void _awaitResultFromSettingsFinal(BuildContext context) async {
  //   await Navigator.push(
  //       context,
  //       MaterialPageRoute(
  //           builder: (context) => SettingsScreen(params: config)));
  //   _controller.setVideoConfig(config.video);
  //   _controller.setAudioConfig(config.audio);
  // }

  Color apiVideoOrange = Colors.orangeAccent;

  /// Display the control bar with buttons to take pictures and record videos.
  Widget _controlRowWidget() {
    final ApiVideoLiveStreamController? liveStreamController = _controller;

    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
      mainAxisSize: MainAxisSize.max,
      children: <Widget>[
        IconButton(
          icon: const Icon(Icons.cameraswitch),
          color: apiVideoOrange,
          onPressed:
              liveStreamController != null ? onSwitchCameraButtonPressed : null,
        ),
        IconButton(
          icon: const Icon(Icons.mic_off),
          color: apiVideoOrange,
          onPressed: liveStreamController != null
              ? onToggleMicrophoneButtonPressed
              : null,
        ),
        IconButton(
          icon: const Icon(Icons.fiber_manual_record),
          color: Colors.red,
          onPressed: liveStreamController != null && !_isStreaming
              ? onStartStreamingButtonPressed
              : null,
        ),
        IconButton(
            icon: const Icon(Icons.stop),
            color: Colors.red,
            onPressed: liveStreamController != null && _isStreaming
                ? onStopStreamingButtonPressed
                : null),
      ],
    );
  }

  void showInSnackBar(String message) {
    ScaffoldMessenger.of(context)
        .showSnackBar(SnackBar(content: Text(message)));
  }

  Future<void> switchCamera() async {
    final ApiVideoLiveStreamController? liveStreamController = _controller;

    if (liveStreamController == null) {
      showInSnackBar('Error: create a camera controller first.');
      return;
    }

    return await liveStreamController.switchCamera();
  }

  Future<void> toggleMicrophone() async {
    final ApiVideoLiveStreamController? liveStreamController = _controller;

    if (liveStreamController == null) {
      showInSnackBar('Error: create a camera controller first.');
      return;
    }

    return await liveStreamController.toggleMute();
  }

  Future<void> startStreaming() async {
    // final ApiVideoLiveStreamController? controller = _controller;
    //
    // if (controller == null) {
    //   print('Error: create a camera controller first.');
    //   return;
    // }
    //
    print('[rtmp]$rtmp');
    try {
      _controller.startStreaming(streamKey: rtmpKey, url: rtmp);
    } catch (e) {
      print('err$e');
    }
    // return await controller.startStreaming(streamKey: 'mm', url: rtmp);
  }

  Future<void> stopStreaming() async {
    final ApiVideoLiveStreamController? controller = _controller;

    if (controller == null) {
      print('Error: create a camera controller first.');
      return;
    }

    return await controller.stopStreaming();
  }

  void onSwitchCameraButtonPressed() {
    switchCamera().then((_) {
      if (mounted) {
        setState(() {});
      }
    }).catchError((error) {
      if (error is PlatformException) {
        _showDialog(
            context, "Error", "Failed to switch camera: ${error.message}");
      } else {
        _showDialog(context, "Error", "Failed to switch camera: $error");
      }
    });
  }

  void onToggleMicrophoneButtonPressed() {
    toggleMicrophone().then((_) {
      if (mounted) {
        setState(() {});
      }
    }).catchError((error) {
      if (error is PlatformException) {
        _showDialog(
            context, "Error", "Failed to toggle mute: ${error.message}");
      } else {
        _showDialog(context, "Error", "Failed to toggle mute: $error");
      }
    });
  }

  var count = 0;

  void onStartStreamingButtonPressed() {
    print("click222");
    setState(() {
      count += 1;
    });
    startStreaming().then((_) {
      if (mounted) {
        setIsStreaming(true);
      }
    }).catchError((error) {
      if (error is PlatformException) {
        _showDialog(
            context, "Error", "Failed to start stream: ${error.message}");
      } else {
        _showDialog(context, "Error", "Failed to start stream: $error");
      }
    });
  }

  void onStopStreamingButtonPressed() {
    stopStreaming().then((_) {
      if (mounted) {
        setIsStreaming(false);
      }
    }).catchError((error) {
      if (error is PlatformException) {
        _showDialog(
            context, "Error", "Failed to stop stream: ${error.message}");
      } else {
        _showDialog(context, "Error", "Failed to stop stream: $error");
      }
    });
  }

  void setIsStreaming(bool isStreaming) {
    setState(() {
      if (isStreaming) {
        // WakelockPlus.enable();
      } else {
        // WakelockPlus.disable();
      }
      _isStreaming = isStreaming;
    });
  }
}

Future<void> _showDialog(
    BuildContext context, String title, String description) async {
  return showDialog<void>(
    context: context,
    barrierDismissible: false, // user must tap button!
    builder: (BuildContext context) {
      return AlertDialog(
        title: Text(title),
        content: SingleChildScrollView(
          child: Text(description),
        ),
        actions: <Widget>[
          TextButton(
            child: const Text('Dismiss'),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
        ],
      );
    },
  );
}

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

I/MediaCodecEncoder( 6991): 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]}
I/MediaCodecEncoder( 6991): Format changed : {max-bitrate=128000, aac-sbr-mode=3, sample-rate=44100, level=0, mime=audio/mp4a-latm, profile=2, channel-count=2, bitrate=128000, csd-0=java.nio.HeapByteBuffer[pos=0 lim=2 cap=2]}
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
E/libEGL  ( 6991): eglMakeCurrentImpl:1100 error 3002 (EGL_BAD_ACCESS)
E/AndroidRuntime( 6991): FATAL EXCEPTION: pool-5-thread-2
E/AndroidRuntime( 6991): Process: com.zhenyi.app.bom, PID: 6991
E/AndroidRuntime( 6991): java.lang.RuntimeException: eglMakeCurrent failed
E/AndroidRuntime( 6991): 	at io.github.thibaultbee.streampack.internal.gl.EglWindowSurface.makeCurrent(EglWindowSurface.kt:136)
E/AndroidRuntime( 6991): 	at io.github.thibaultbee.streampack.internal.encoders.VideoMediaCodecEncoder$CodecSurface.onFrameAvailable$lambda$9(VideoMediaCodecEncoder.kt:255)
E/AndroidRuntime( 6991): 	at io.github.thibaultbee.streampack.internal.encoders.VideoMediaCodecEncoder$CodecSurface.$r8$lambda$beCZ0tKmLlcQAOcowgyTvNzP_wI(Unknown Source:0)
E/AndroidRuntime( 6991): 	at io.github.thibaultbee.streampack.internal.encoders.VideoMediaCodecEncoder$CodecSurface$$ExternalSyntheticLambda2.run(Unknown Source:4)
E/AndroidRuntime( 6991): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime( 6991): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime( 6991): 	at java.lang.Thread.run(Thread.java:923)
I/Process ( 6991): Sending signal. PID: 6991 SIG: 9
@frankcjw frankcjw added the bug Something isn't working label May 4, 2024
@ThibaultBee
Copy link
Member

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.

@frankcjw
Copy link
Author

frankcjw commented May 6, 2024

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

@ThibaultBee
Copy link
Member

When did this happen? When calling startStream, startPreview,...?

@frankcjw
Copy link
Author

frankcjw commented May 6, 2024

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

@ThibaultBee
Copy link
Member

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 🤷

@frankcjw
Copy link
Author

frankcjw commented May 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants