Comments (7)
/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.
Hi @X-SLAYER ,
Do you have any plan on this to resolve.
Thanks
from flutter_overlay_window.
Happened on debug as well, I have google pixel 7
from flutter_overlay_window.
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:
- Run your app and start the overlay.
- 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)
- Does it use Google Play services? HOT 1
- You can use the resize overlay and pass the enableDrag params HOT 2
- Could not run the example
- FlutterOverlayWindow.showOverlay(height: WindowSize.fullcover) wont work
- Listview scroll event conflicts with FlutterOverlayWindow drag, HOT 5
- Save overlay position
- Open the main app from floating window? HOT 6
- MissingPluginException HOT 1
- Open Overlay from background when app is kill state HOT 6
- Android 14 requirese foregroundServiceType HOT 1
- Does not display all objects HOT 1
- I can't display my data on the overlay window. HOT 3
- warning red
- Add support for android API 34 HOT 1
- Height doesn't account for status bar
- Use of `FlutterEngineGroup` instead of simply using `FlutterEngine` HOT 1
- Overlay stops sending messages to UI when it's turned on after previously being closed after app termination
- Unable to create multiple overlay window. HOT 4
- Please add more flags to show when phone is looked HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_overlay_window.