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

Unhandled Exception: Bad state: Cannot add event after closing #50

Open
GolakiyaVishal opened this issue Aug 7, 2021 · 2 comments
Open

Comments

@GolakiyaVishal
Copy link

This is full error log.

[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Bad state: Cannot add event after closing
#0      _StreamController.add (dart:async/stream_controller.dart:553:24)
#1      GRPCWebSignal.trickle (package:flutter_ion/src/signal/signal_grpc_impl.dart:132:20)
#2      Transport.create.<anonymous closure> (package:flutter_ion/src/client.dart:45:14)
#3      RTCPeerConnectionNative.eventListener (package:flutter_webrtc/src/native/rtc_peerconnection_impl.dart:102:25)
#4      _rootRunUnary (dart:async/zone.dart:1362:47)
#5      _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#6      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#7      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#8      _DelayedData.perform (dart:async/stream_impl.dart:591:14)
#9      _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
#10     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663:7)
#11     _rootRun (dart:async/zone.dart:1346:47)
#12     _CustomZone.run (dart:async/zone.dart:1258:19)
#13     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
#14     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
#15     _rootRun (dart:async/zone.dart:1354:13)
#16     _CustomZone.run (dart:async/zone.dart:1258:19)
#17     _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
#18     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
#19     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#20     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

This is flutter doctor

[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19043.1110], locale en-US)
    • Flutter version 2.2.3 at C:\src\flutter
    • Framework revision f4abaa0735 (5 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at C:\Users\omshivay\AppData\Local\Android\Sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = C:\Users\omshivay\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Android Studio (version 4.1.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[√] Connected device (3 available)
    • SM A500G (mobile) • ee1ddaed • android-arm    • Android 6.0.1 (API 23)
    • Chrome (web)      • chrome   • web-javascript • Google Chrome 92.0.4515.131
    • Edge (web)        • edge     • web-javascript • Microsoft Edge 92.0.902.62

• No issues found!

I am using
flutter_ion: ^0.5.1

@manish-raje
Copy link

manish-raje commented Dec 30, 2021

We are also facing the similar issue when deployed as web solution and macOS app. We need a facility to change the video conference room for the user. So, I have user interface design which allows user to move from one room to another room.

Following error is occurring with gRPC channel. This error occurred when the user tries to join another room from existing room.

Uncaught Bad state: Cannot add event after closing
    at Object.wrapException (https://<serverurl>/main.dart.js:13721:17)
    at _AsyncStreamController.add$1 (https://<serverurl>/main.dart.js:62034:17)
    at https://<serverurl>/main.dart.js:120075:52
    at _wrapJsFunctionForAsync_closure.$protected (https://<serverurl>/main.dart.js:23103:15)
    at _wrapJsFunctionForAsync_closure.call$2 (https://<serverurl>/main.dart.js:60915:12)
    at Object._asyncStartSync (https://<serverurl>/main.dart.js:23067:20)
    at WebSocketTransportStream__runRequest_closure0.call$1 (https://<serverurl>/main.dart.js:120080:16)
    at _RootZone.runUnaryGuarded$1$2 (https://<serverurl>/main.dart.js:63018:13)
    at _ControllerSubscription._sendData$1 (https://<serverurl>/main.dart.js:62385:19)
    at _ControllerSubscription._async$_add$1 (https://<serverurl>/main.dart.js:62334:14)

Flutter doctor from the machine where it is built and deployed -

> flutter doctor -v
[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-arm, locale en-IN)
    • Flutter version 2.5.2 at /Users/manishraje/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 3595343e20 (3 months ago), 2021-09-30 12:58:18 -0700
    • Engine revision 6ac856380f
    • Dart version 2.14.3

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/manishraje/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 13.1, Build version 13A1030d
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.63.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.29.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 11.6 20G165 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 96.0.4664.110

! Doctor found issues in 1 category.

During the debugging we found that the crash happens here - flutter_ion 1.0.0 lib/src/signal/grpc-web/transport/websocket_transport.dart.

      _channel.stream.listen((message) async {
        final listBuffer = <int>[];
        for (var i = 0; i < message.length; i++) {
          listBuffer.add(message[i]);
        }
=>        _incomingProcessor.add(Uint8List.fromList(listBuffer).buffer);
      }, onDone: _onDone(this), onError: _onError);

This happens intermittently. But it is a critical because once this happens the next room join doesn't happen or/sometimes the video/audio streams in the conference are broken. To circumvent this, we created separate instance of IonController for every meeting page, so it connect properly on next room join. But still the underlying problem doesn't solve.

Regards,
Manish

@wujianqiangwjq
Copy link

Me too!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants