flutter_background_service
flutter_background_service copied to clipboard
E/BackgroundService: callback handle not found
2021-06-05 08:21:46.045 17905-17905/? E/BackgroundService: callback handle not found
Other Log :
2021-06-05 08:30:53.035 1790-2065/? I/ActivityManager: Force stopping in.canews.pythonide appid=10547 user=0: from pid 22792
2021-06-05 08:30:53.041 1790-2065/? I/ActivityManager: Force stopping in.canews.pythonide appid=10547 user=11: from pid 22792
2021-06-05 08:30:53.346 1790-2118/? I/ActivityTaskManager: START u0 {act=android.intent.action.RUN flg=0x30000000 cmp=in.canews.pythonide/.MainActivity (has extras)} from uid 2000
2021-06-05 08:30:53.373 1790-1861/? I/ActivityManager: Start proc 6651:in.canews.pythonide/u0a547 for pre-top-activity {in.canews.pythonide/in.canews.pythonide.MainActivity}
2021-06-05 08:30:53.399 6651-6651/? I/chatty: uid=10547(in.canews.pythonide) identical 2 lines
2021-06-05 08:30:53.420 6651-6651/? I/TetheringManager: registerTetheringEventCallback:in.canews.pythonide
2021-06-05 08:30:53.437 6651-6651/? W/anews.pythonide: type=1400 audit(0.0:142110): avc: denied { read } for name="max_map_count" dev="proc" ino=17290730 scontext=u:r:untrusted_app_29:s0:c35,c258,c512,c768 tcontext=u:object_r:proc_max_map_count:s0 tclass=file permissive=0 app=in.canews.pythonide
2021-06-05 08:30:53.462 1790-2115/? D/UntrustedWifiNetworkFactory: got request NetworkRequest [ TRACK_DEFAULT id=10045, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED Uid: 10547 AdministratorUids: [] RequestorUid: 10547 RequestorPackageName: in.canews.pythonide] ] with score 60 and providerId 6
2021-06-05 08:30:53.462 1790-2170/? D/WIFI_AWARE_FACTORY: got request NetworkRequest [ TRACK_DEFAULT id=10045, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED Uid: 10547 AdministratorUids: [] RequestorUid: 10547 RequestorPackageName: in.canews.pythonide] ] with score 60 and providerId 6
2021-06-05 08:30:53.462 1790-2171/? D/Ethernet: got request NetworkRequest [ TRACK_DEFAULT id=10045, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED Uid: 10547 AdministratorUids: [] RequestorUid: 10547 RequestorPackageName: in.canews.pythonide] ] with score 60 and providerId 6
2021-06-05 08:30:53.463 2811-2811/? D/PhoneSwitcherNetworkRequstListener: got request NetworkRequest [ TRACK_DEFAULT id=10045, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED Uid: 10547 AdministratorUids: [] RequestorUid: 10547 RequestorPackageName: in.canews.pythonide] ] with score 60 and providerId 6
2021-06-05 08:30:53.463 1790-2115/? D/WifiNetworkFactory: got request NetworkRequest [ TRACK_DEFAULT id=10045, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED Uid: 10547 AdministratorUids: [] RequestorUid: 10547 RequestorPackageName: in.canews.pythonide] ] with score 60 and providerId 6
2021-06-05 08:30:53.498 6651-22921/? D/DownloadWorker: DownloadWorker{url=https://cdn.jsdelivr.net/gh/ngosang/trackerslist/trackers_best_ip.txt,filename=null,savedDir=/data/data/in.canews.pythonide/files/trackers,header=,isResume=false
2021-06-05 08:30:53.498 6651-22922/? D/DownloadWorker: DownloadWorker{url=https://cdn.jsdelivr.net/gh/ngosang/trackerslist/trackers_all_ip.txt,filename=null,savedDir=/data/data/in.canews.pythonide/files/trackers,header=,isResume=false
2021-06-05 08:30:53.629 1790-1858/? I/ActivityTaskManager: Displayed in.canews.pythonide/.MainActivity: +275ms
2021-06-05 08:30:53.652 1790-2094/? W/InputDispatcher: channel '73ea9e7 in.canews.pythonide/in.canews.pythonide.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0xd
2021-06-05 08:30:53.652 1790-2094/? E/InputDispatcher: channel '73ea9e7 in.canews.pythonide/in.canews.pythonide.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2021-06-05 08:30:53.653 1790-4001/? D/ConnectivityService: ConnectivityService NetworkRequestInfo binderDied(NetworkRequest [ TRACK_DEFAULT id=10045, [ Capabilities: INTERNET&NOT_RESTRICTED&TRUSTED Uid: 10547 AdministratorUids: [] RequestorUid: 10547 RequestorPackageName: in.canews.pythonide] ], android.os.BinderProxy@b17dfc4)
2021-06-05 08:30:53.653 1790-3060/? I/WindowManager: WIN DEATH: Window{73ea9e7 u0 in.canews.pythonide/in.canews.pythonide.MainActivity}
2021-06-05 08:30:53.653 1790-2118/? I/ActivityManager: Process in.canews.pythonide (pid 6651) has died: fg TOP
2021-06-05 08:30:53.653 1790-3060/? W/InputDispatcher: Attempted to unregister already unregistered input channel '73ea9e7 in.canews.pythonide/in.canews.pythonide.MainActivity (server)'
2021-06-05 08:30:53.657 1790-2118/? W/ActivityManager: Scheduling restart of crashed service in.canews.pythonide/androidx.work.impl.background.systemjob.SystemJobService in 1000ms for connection
2021-06-05 08:30:53.658 1790-2118/? W/ActivityTaskManager: Force removing ActivityRecord{8ee3228 u0 in.canews.pythonide/.MainActivity t3466}: app died, no saved state
2021-06-05 08:30:58.361 1165-22810/? I/iorapd: Perfetto TraceBuffer saved to file: /data/misc/iorapd/in.canews.pythonide/4/in.canews.pythonide.MainActivity/raw_traces/1622862058359173889.perfetto_trace.pb
2021-06-05 08:31:03.743 1790-1861/? I/ActivityManager: Start proc 22993:in.canews.pythonide/u0a547 for service {in.canews.pythonide/androidx.work.impl.background.systemjob.SystemJobService}
2021-06-05 08:31:03.801 22993-22993/? I/chatty: uid=10547(in.canews.pythonide) identical 2 lines
2021-06-05 08:31:03.821 22993-22993/? I/TetheringManager: registerTetheringEventCallback:in.canews.pythonide
Usually Happens when app is cleared from recents.
@canewsin does this happen in release mode?
@ekasetiawans the log provided here, belongs to release build mode.
@canewsin does this also happen to the sample project?
@ekasetiawans didn't tried that!
this can happen if the flutter build binary output is different when initializing the background service and when the application auto-starts after cleaning from recents. But this happens more often in debug mode. So I still can't figure out the real cause.
![drawing](https://user-images.githubusercontent.com/26790557/121115302-8cbc4200-c832-11eb-8457-f1a3a31d8ec8.png)
Screenshot when phone restarts, in previous versions of package, it works normally, task doesn't start until app is opened.
I updated to latest version from v0.0.1+18
I just installed the plugin and exactly same problem
flutter --version
Flutter 3.0.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision fb57da5f94 (3 weeks ago) • 2022-05-19 15:50:29 -0700
Engine • revision caaafc5604
Tools • Dart 2.17.1 • DevTools 2.12.2
code are from sample
Future<void> initializeService() async {
backgroundServer = FlutterBackgroundService();
await backgroundServer.configure(
androidConfiguration: AndroidConfiguration(
// this will executed when app is in foreground or background in separated isolate
onStart: onStart,
// auto start backgroundServer
autoStart: true,
isForegroundMode: true,
),
iosConfiguration: IosConfiguration(
// auto start backgroundServer
autoStart: true,
// this will executed when app is in foreground in separated isolate
onForeground: onStart,
// you have to enable background fetch capability on xcode project
onBackground: onIosBackground,
),
);
}
void onStart(ServiceInstance service) async {
// Only available for flutter 3.0.0 and later
DartPluginRegistrant.ensureInitialized();
// For flutter prior to version 3.0.0
// We have to register the plugin manually
if (service is AndroidServiceInstance) {
service.on('setAsForeground').listen((event) {
service.setAsForegroundService();
});
service.on('setAsBackground').listen((event) {
service.setAsBackgroundService();
});
}
service.on('stopService').listen((event) {
service.stopSelf();
});
Timer.periodic(const Duration(seconds: 3), (timer) async {
// bring to foreground
if (service is AndroidServiceInstance) {
service.setForegroundNotificationInfo(
title: "My App Service",
content: "Updated at ${DateTime.now()}",
);
}
/// you can see this log in logcat
print('FLUTTER BACKGROUND SERVICE: ${DateTime.now()}');
service.invoke(
'update',
{
"current_date": DateTime.now().toIso8601String(),
},
);
});
}
logs in debug panel in VScode
E/BackgroundService(15312): callback handle not found
D/BackgroundService(15312): runService
E/BackgroundService(15312): callback handle not found
D/BackgroundService(15312): runService
E/BackgroundService(15312): callback handle not found
D/BackgroundService(15312): runService
E/BackgroundService(15312): callback handle not found
D/BackgroundService(15312): runService
E/BackgroundService(15312): callback handle not found```
Would you please create a sample project, and specify which Emulator used to reproduce this?