From 78af8e12a0b830a391f6d909f149bb26e6a4fba8 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Wed, 11 Oct 2023 15:00:17 +0800 Subject: [PATCH] add infinite loop check for pick_ffi --- lib/filament_controller_ffi.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/filament_controller_ffi.dart b/lib/filament_controller_ffi.dart index 22a5b7e6..d80b663e 100644 --- a/lib/filament_controller_ffi.dart +++ b/lib/filament_controller_ffi.dart @@ -809,12 +809,16 @@ class FilamentControllerFFI extends FilamentController { } final outPtr = calloc(1); outPtr.value = 0; - print("height ${size.height.toInt()} y $y"); _lib.pick_ffi(_viewer!, x, size.height.toInt() - y, outPtr); + int wait = 0; while (outPtr.value == 0) { - await Future.delayed(Duration(milliseconds: 100)); - print("Waiting"); + await Future.delayed(Duration(milliseconds: 50)); + wait++; + if (wait > 10) { + calloc.free(outPtr); + throw Exception("Failed to get picking result"); + } } var entityId = outPtr.value;