Perf: Do not wait for objectService init during app start
This commit is contained in:
parent
b79ec21ca3
commit
6412f8901e
2 changed files with 8 additions and 3 deletions
|
@ -187,9 +187,9 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
|
|||
});
|
||||
}
|
||||
FeatureFlagService.instance.init();
|
||||
if (FeatureFlagService.instance.isInternalUserOrDebugBuild()) {
|
||||
await ObjectDetectionService.instance.init();
|
||||
}
|
||||
|
||||
unawaited(ObjectDetectionService.instance.init());
|
||||
|
||||
_logger.info("Initialization done");
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ class ObjectDetectionService {
|
|||
late IsolateUtils _isolateUtils;
|
||||
|
||||
ObjectDetectionService._privateConstructor();
|
||||
bool inInitiated = false;
|
||||
|
||||
Future<void> init() async {
|
||||
_isolateUtils = IsolateUtils();
|
||||
|
@ -40,6 +41,7 @@ class ObjectDetectionService {
|
|||
} catch (e, s) {
|
||||
_logger.severe("Could not initialize sceneclassifier", e, s);
|
||||
}
|
||||
inInitiated = true;
|
||||
}
|
||||
|
||||
static ObjectDetectionService instance =
|
||||
|
@ -47,6 +49,9 @@ class ObjectDetectionService {
|
|||
|
||||
Future<List<String>> predict(Uint8List bytes) async {
|
||||
try {
|
||||
if (!inInitiated) {
|
||||
return Future.error("ObjectDetectionService init is not completed");
|
||||
}
|
||||
final results = <String>{};
|
||||
results.addAll(await _getObjects(bytes));
|
||||
results.addAll(await _getMobileNetResults(bytes));
|
||||
|
|
Loading…
Add table
Reference in a new issue