medyas / flutter_qiblah

Flutter Qiblah is a plugin that allows you to display Qiblah direction in you app with support for both Android and iOS.
https://pub.dev/packages/flutter_qiblah
MIT License
127 stars 91 forks source link

getting Unhandled Exception: Bad state: You cannot close the subject while items are being added from addStream #4

Closed kw2019ltd closed 3 years ago

kw2019ltd commented 4 years ago

hi i copied the example you provided , i am getting below error in logs while trying to press back button.

see below

  @override
  void dispose() {
    _locationStreamController.close();
    FlutterQiblah().dispose();
    super.dispose();
  }

Performing hot reload...
Syncing files to device HD1903...
Reloaded 3 of 1365 libraries in 529ms.
E/flutter ( 4181): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: You cannot close the subject while items are being added from addStream
E/flutter ( 4181): #0 Subject.close (package:rxdart/src/subjects/subject.dart:152:7)
E/flutter ( 4181): #1 FlutterCompass.dispose (package:flutter_compass/flutter_compass.dart:35:21)
E/flutter ( 4181): #2 FlutterQiblah.dispose (package:flutter_qiblah/flutter_qiblah.dart:87:22)
E/flutter ( 4181): #3 _QiblahCompassState.dispose (package:salatkapp/ui/prayer/qibla/qiblah_compass.dart:89:21)
E/flutter ( 4181): #4 StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4729:12)
E/flutter ( 4181): #5 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1922:13)
E/flutter ( 4181): #6 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #7 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14)
E/flutter ( 4181): #8 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #9 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #10 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14)
E/flutter ( 4181): #11 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #12 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #13 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14)
E/flutter ( 4181): #14 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #15 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #16 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14)
E/flutter ( 4181): #17 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #18 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #19 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5929:16)
E/flutter ( 4181): #20 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #21 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #22 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14)
E/flutter ( 4181): #23 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #24 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #25 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14)
E/flutter ( 4181): #26 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #27 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #28 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14)
E/flutter ( 4181): #29 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #30 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #31 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5817:14)
E/flutter ( 4181): #32 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #33 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #34 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14)
E/flutter ( 4181): #35 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #36 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #37 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5817:14)
E/flutter ( 4181): #38 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13)
E/flutter ( 4181): #39 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7)
E/flutter ( 4181): #40 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14)
E/flutter ( 4181): #41
W/IInputConnectionWrapper( 4181): getExtractedText on inactive InputConnection
W/IInputConnectionWrapper( 4181): getTextBeforeCursor on inactive InputConnection
D/OnePlusJankManager( 4181): Chor uploadMDM JANK_TYPE_ONCE mViewTitle = kw.ltd.salatkapp/kw.ltd.salatkapp.MainActivity--- jank level = 1
medyas commented 4 years ago

@kw2019ltd Can you share the full app that you are using ?

kw2019ltd commented 4 years ago

yes easy i take you example folder and replace main.dart with below main and run it you will face this issue main.zip

once you take it just press the Button "open Qiblah" , Qiblah page will load , press back to go to main screen you will see below in consol

I/_qiblah_exampl(27331): Waiting for a blocking GC ProfileSaver I/_qiblah_exampl(27331): WaitForGcToComplete blocked ProfileSaver on ProfileSaver for 14.214ms W/IInputConnectionWrapper(27331): getExtractedText on inactive InputConnection W/IInputConnectionWrapper(27331): getTextBeforeCursor on inactive InputConnection D/DecorView(27331): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@288388a[] E/flutter (27331): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Bad state: You cannot close the subject while items are being added from addStream E/flutter (27331): #0 Subject.close (package:rxdart/src/subjects/subject.dart:152:7) E/flutter (27331): #1 FlutterCompass.dispose (package:flutter_compass/flutter_compass.dart:35:21) E/flutter (27331): #2 FlutterQiblah.dispose (package:flutter_qiblah/flutter_qiblah.dart:87:22) E/flutter (27331): #3 _QiblahCompassState.dispose (package:flutter_qiblah_example/qiblah_compass.dart:86:21) E/flutter (27331): #4 StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4729:12) E/flutter (27331): #5 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1922:13) E/flutter (27331): #6 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #7 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14) E/flutter (27331): #8 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #9 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #10 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14) E/flutter (27331): #11 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #12 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #13 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14) E/flutter (27331): #14 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #15 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #16 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14) E/flutter (27331): #17 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #18 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #19 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5929:16) E/flutter (27331): #20 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #21 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #22 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14) E/flutter (27331): #23 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #24 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #25 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14) E/flutter (27331): #26 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #27 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #28 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14) E/flutter (27331): #29 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #30 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #31 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5817:14) E/flutter (27331): #32 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #33 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #34 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14) E/flutter (27331): #35 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #36 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #37 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:5817:14) E/flutter (27331): #38 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1918:13) E/flutter (27331): #39 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1920:7) E/flutter (27331): #40 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4556:14) E/flutter (27331): #41

kw2019ltd commented 4 years ago

salam, did you tried it?

medyas commented 4 years ago

Yes. It's caused by the flutter_compass dispose method, it never happened to me before. Will try to test it more in the next couple of days, in the meantime you can wrap it in a try catch block .

By the way, I already have an app in the play store and it uses the plugin and it has no errors

kw2019ltd commented 4 years ago

i can't wrap it with try catch as its failing in the plugin code not in my code , its not carshe causing.

better to fix it maybe it can cause memory leaks

medyas commented 4 years ago

I am currently busy, but will try to have a deep look into the problem this weekend.

kw2019ltd commented 4 years ago

Thanks by the way what is your app name in Google play store?

On Wed, Jun 10, 2020, 22:49 medyas notifications@github.com wrote:

I am currently busy, but will try to have a deep look into the problem this weekend.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/medyas/flutter_qiblah/issues/4#issuecomment-642221046, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJEI6TSM23AA66XTQYIOPLRV7PUNANCNFSM4NZULCPA .

medyas commented 4 years ago

Thanks by the way what is your app name in Google play store? On Wed, Jun 10, 2020, 22:49 medyas @.***> wrote: I am currently busy, but will try to have a deep look into the problem this weekend. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#4 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJEI6TSM23AA66XTQYIOPLRV7PUNANCNFSM4NZULCPA .

Here is the play store link.

kw2019ltd commented 4 years ago

Hi did you had a chance to check the issue

On Wed, Jun 10, 2020, 23:15 medyas notifications@github.com wrote:

Thanks by the way what is your app name in Google play store? … <#m3628161360176631821> On Wed, Jun 10, 2020, 22:49 medyas @.***> wrote: I am currently busy, but will try to have a deep look into the problem this weekend. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#4 (comment) https://github.com/medyas/flutter_qiblah/issues/4#issuecomment-642221046>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJEI6TSM23AA66XTQYIOPLRV7PUNANCNFSM4NZULCPA .

Here is the play store link https://play.google.com/store/apps/details?id=de.nbsev.darassalam.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/medyas/flutter_qiblah/issues/4#issuecomment-642233794, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALJEI6T5L2VF5XRZFOJT6U3RV7SXVANCNFSM4NZULCPA .

medyas commented 4 years ago

@kw2019ltd unfortunately i didn't. I currently have a lot of work but will try to take a look at this in next couple of days and inform you of any updates.

medyas commented 4 years ago

@kw2019ltd Hi, So i have tested this issue and turns out it's the flutter_compasspackage bug, as when trying to call it's dispose method the crash happens. I have filled an issue in the github repo and hopefully will get some feedback soon. Thnx