Git Product home page Git Product logo

Comments (4)

chinmay4github1987 avatar chinmay4github1987 commented on July 1, 2024

/MethodChannel#x-slayer/overlay_channel( 6714): Failed to handle method call E/MethodChannel#x-slayer/overlay_channel( 6714): java.lang.IllegalStateException: Not allowed to start service Intent { flg=0x30000000 cmp=com.qspiders.flutter_project/flutter.overlay.window.flutter_overlay_window.OverlayService (has extras) }: app is in background uid UidRecord{ef07ad0 u0a168 LAST bg:+27m44s110ms idle change:cached procs:1 seq(0,0,0)} E/MethodChannel#x-slayer/overlay_channel( 6714): at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1616) E/MethodChannel#x-slayer/overlay_channel( 6714): at android.app.ContextImpl.startService(ContextImpl.java:1571) E/MethodChannel#x-slayer/overlay_channel( 6714): at android.content.ContextWrapper.startService(ContextWrapper.java:669) E/MethodChannel#x-slayer/overlay_channel( 6714): at flutter.overlay.window.flutter_overlay_window.FlutterOverlayWindowPlugin.onMethodCall(FlutterOverlayWindowPlugin.java:110) E/MethodChannel#x-slayer/overlay_channel( 6714): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267) E/MethodChannel#x-slayer/overlay_channel( 6714): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/MethodChannel#x-slayer/overlay_channel( 6714): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/MethodChannel#x-slayer/overlay_channel( 6714): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/MethodChannel#x-slayer/overlay_channel( 6714): at android.os.Handler.handleCallback(Handler.java:883) E/MethodChannel#x-slayer/overlay_channel( 6714): at android.os.Handler.dispatchMessage(Handler.java:100) E/MethodChannel#x-slayer/overlay_channel( 6714): at android.os.Looper.loop(Looper.java:214) E/MethodChannel#x-slayer/overlay_channel( 6714): at android.app.ActivityThread.main(ActivityThread.java:7356) E/MethodChannel#x-slayer/overlay_channel( 6714): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#x-slayer/overlay_channel( 6714): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491) E/MethodChannel#x-slayer/overlay_channel( 6714): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940) E/flutter ( 6714): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, Not allowed to start service Intent { flg=0x30000000 cmp=com.qspiders.flutter_project/flutter.overlay.window.flutter_overlay_window.OverlayService (has extras) }: app is in background uid UidRecord{ef07ad0 u0a168 LAST bg:+27m44s110ms idle change:cached procs:1 seq(0,0,0)}, null, java.lang.IllegalStateException: Not allowed to start service Intent { flg=0x30000000 cmp=com.qspiders.flutter_project/flutter.overlay.window.flutter_overlay_window.OverlayService (has extras) }: app is in background uid UidRecord{ef07ad0 u0a168 LAST bg:+27m44s110ms idle change:cached procs:1 seq(0,0,0)} E/flutter ( 6714): at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1616) E/flutter ( 6714): at android.app.ContextImpl.startService(ContextImpl.java:1571) E/flutter ( 6714): at android.content.ContextWrapper.startService(ContextWrapper.java:669) E/flutter ( 6714): at flutter.overlay.window.flutter_overlay_window.FlutterOverlayWindowPlugin.onMethodCall(FlutterOverlayWindowPlugin.java:110) E/flutter ( 6714): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267) E/flutter ( 6714): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/flutter ( 6714): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/flutter ( 6714): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/flutter ( 6714): at android.os.Handler.handleCallback(Handler.java:883) E/flutter ( 6714): at android.os.Handler.dispatchMessage(Handler.java:100) E/flutter ( 6714): at android.os.Looper.loop(Looper.java:214) E/flutter ( 6714): at android.app.ActivityThread.main(ActivityThread.java:7356) E/flutter ( 6714): at java.lang.reflect.Method.invoke(Native Method) E/flutter ( 6714): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491) E/flutter ( 6714): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940) E/flutter ( 6714): ) E/flutter ( 6714): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7) E/flutter ( 6714): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:322:18) E/flutter ( 6714): <asynchronous suspension> E/flutter ( 6714): #2 FlutterOverlayWindow.showOverlay (package:flutter_overlay_window/src/overlay_window.dart:54:5) E/flutter ( 6714): <asynchronous suspension> E/flutter ( 6714): #3 phoneStateBackgroundCallbackHandler (package:flutter_project/main.dart:279:7) E/flutter ( 6714): <asynchronous suspension>
Getting error whenever an inocming call comes in background.

from flutter_overlay_window.

OsamaQureshi796 avatar OsamaQureshi796 commented on July 1, 2024

Hi @X-SLAYER ,

Do you have any plan on this to resolve.

Thanks

from flutter_overlay_window.

s4-ali avatar s4-ali commented on July 1, 2024

Happened on debug as well, I have google pixel 7

from flutter_overlay_window.

rorystephenson avatar rorystephenson commented on July 1, 2024

Android may decide to kill the overlay service for various reasons (e.g. low ram), and since START_STICKY is used it may later decide to restart the service. When this happens OverlayService.java tries to access variables which were created outside of the service and are no longer set, for example FlutterEngineCache.getInstance().get(OverlayConstants.CACHED_TAG) returns null and that leads to a NPE when we try to use that value.

You have two options to avoid these crashes:

  • Change START_STICKY to START_NOT_STICKY. This will prevent the crash but it also means the overlay won't be restarted if Android decides to close it.
  • Re-architect OverlayService.java to manage all of the variables it needs access to so that when it is restarted it doesn't refer to variables from other classes that may no longer exist. I chose this path in my own fork and made it so the flutter engine is only created when the overlay starts and is managed totally by the overlay. Unfortunately my fork was already heavily modified to suit my own needs so upstreaming a fix is not feasible. It also changes how the overlay system works (one engine per overlay, created when the overlay service is started, rather than a single engine created at app start and shared across overlays).

Apart from explaining why this happens the only other help I can really offer is a suggestion of how to reproduce the error if you want to keep START_STICKY and try to fix it yourself:

  1. Run your app and start the overlay.
  2. Use the Fill Memory app or a similar app to fill up your device memory. I selected the "FILL UNTIL MEM LOW" option. For me around 3/4 times Android would kill the overlay service and then when Fill Memory stopped filling the memory Android would try to restart the overlay service and it would fail with a NPE.

from flutter_overlay_window.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.