Skip to content

When app is hot restarted getting different kinds of errors #72

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

Closed
naveenbharadwaj19 opened this issue Apr 24, 2021 · 7 comments
Closed

Comments

@naveenbharadwaj19
Copy link

plugin version : 2.0.0

flutter doctor -v`
[√] Flutter (Channel stable, 2.0.2, on Microsoft Windows [Version 10.0.19041.867], locale en-IN)
    • Flutter version 2.0.2 at D:\OTHER FILES D\CS ALL FOLD\Flutter main sdk\flutter
    • Framework revision 8962f6dc68 (6 weeks ago), 2021-03-11 13:22:20 -0800
    • Engine revision 5d8bf811b3
    • Dart version 2.12.1

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at D:\Android_SDK
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = D:\Android_SDK
    • Java binary at: D:\Android studio main\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • 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 D:\Android studio main
    • 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 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.53.2)
    • VS Code at C:\Users\bhara\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.18.1

[√] Connected device (3 available)
    • Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • Chrome (web)                       • chrome        • web-javascript • Google Chrome 89.0.4389.128
    • Edge (web)                         • edge          • web-javascript • Microsoft Edge 90.0.818.42

• No issues found!

Error when hot restarted :

Error handling 'checkPlatformOverride' custom request: method not available: ext.flutter.platformOverride
Error handling 'checkBrightnessOverride' custom request: method not available: ext.flutter.brightnessOverride
Error handling 'checkIsWidgetCreationTracked' custom request: method not available: ext.flutter.inspector.isWidgetCreationTracked
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): Failed to open event stream
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): java.util.NoSuchElementException
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at java.util.LinkedList.removeFirst(LinkedList.java:270)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at java.util.LinkedList.remove(LinkedList.java:685)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at com.rmawatson.flutterisolate.FlutterIsolatePlugin.onListen(FlutterIsolatePlugin.java:174)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:188)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:167)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at android.os.MessageQueue.next(MessageQueue.java:336)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at android.os.Looper.loop(Looper.java:174)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at android.app.ActivityThread.main(ActivityThread.java:7356)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at java.lang.reflect.Method.invoke(Native Method)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
I/chatty  ( 6924): uid=10137(com.company.Explore_Dating) identical 1 line
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): Failed to open event stream
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): java.util.NoSuchElementException
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at java.util.LinkedList.removeFirst(LinkedList.java:270)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at java.util.LinkedList.remove(LinkedList.java:685)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at com.rmawatson.flutterisolate.FlutterIsolatePlugin.onListen(FlutterIsolatePlugin.java:174)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onListen(EventChannel.java:188)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:167)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at android.os.MessageQueue.next(MessageQueue.java:336)
E/EventChannel#com.rmawatson.flutterisolate/event( 6924): 	at android.os.Looper.loop(Looper.java:174)

The following PlatformException was thrown while activating platform stream on channel com.rmawatson.flutterisolate/event:
PlatformException(error, null, null, null)

When the exception was thrown, this was the stack
#0      StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:581
#1      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:158
<asynchronous suspension>

Code :

void isolate(String message) async {
  // this functions will use firebase plugins
  try {
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp(); // initialize firebase app
    function1(message); // update data when button is pressed
    function2(message); // do some backend work
  } catch (error) {
    print("Error");
  }
}
  1. Why hot reload is not working when i change a piece of code ? everytime i need kill and run the app again
  2. Do i need to kill this isolate on my own or will it terminate itself when the work is done ? (i need this isolate only when a button is pressed after that i don't want them to run on separate memory space)
@nmfisher
Copy link
Collaborator

nmfisher commented Apr 25, 2021

  1. Why hot reload is not working when i change a piece of code ? everytime i need kill and run the app again

a) I do have a fix for avoiding the NoSuchElementException on hot reload (will merge in the near future).
b) However, see dart-lang/sdk#44640 - even after we fix the crash, a hot reload will re-spawn the isolate successfully, but only with the original code. The hot reload won't reflect anything that was changed inside the isolate. This is a Dart issue that hasn't been fixed yet.

  1. Do i need to kill this isolate on my own or will it terminate itself when the work is done ? (i need this isolate only when a button is pressed after that i don't want them to run on separate memory space)

I'm not 100% sure (I need to look into it a bit further), but I strongly suspect you should kill any isolate after it's finished its work. This is the approach taken in Flutter compute() so I advise you do the same.

@naveenbharadwaj19
Copy link
Author

@nmfisher what about the Platformexception ?
The following PlatformException was thrown while activating platform stream on channel com.rmawatson.flutterisolate/event:

PlatformException(error, null, null, null)

When the exception was thrown, this was the stack
#0      StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:581
#1      MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:158
<asynchronous suspension>
  • I noticed something even after adding FlutterIsolate.spawn(fun,msg) inside the button i'm getting a log message skipping x frames .The application may be doing too much work on its main thread why ?

@nmfisher
Copy link
Collaborator

I suspect the PlatformException is simply thrown due to the NoSuchElementException being thrown, so fixing the latter should fix the former.

For the "application may be doing too much work on its main thread", do you see this in profile/release mode or just debug mode? I encounter this regularly and just attribute it to the usual sluggishness of Flutter's debug mode. I believe it's a warning propagated from Android's main thread (which is different from Flutter's main thread), which is intended to tell Android developers that they should be moving certain work off-thread. Unless it's causing noticeable jank in a release build, I would ignore it.

@naveenbharadwaj19
Copy link
Author

@nmfisher

I suspect the PlatformException is simply thrown due to the NoSuchElementException being thrown, so fixing the latter should fix the former.

Do i need to wait for flutter_isolate new version ?

do you see this in profile/release mode or just debug mode?

Yes i'm seeing it on debug mode . I haven't tried with profile/release mode

@nmfisher
Copy link
Collaborator

nmfisher commented Apr 25, 2021 via email

@ghost
Copy link

ghost commented May 9, 2021

UP!

@nmfisher
Copy link
Collaborator

This should be fixed by #78, you can try 2.0.1-pre on pub and reopen this issue if you're still experiencing errors.

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

2 participants