khoren93 / flutter_zxing

Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
https://pub.dev/packages/flutter_zxing
MIT License
88 stars 50 forks source link

App Crashes: FATAL EXCEPTION: pool-109-thread-1 (java.lang.IllegalArgumentException: Each request must have at least one Surface target) #139

Open Venkat-polagani7 opened 2 months ago

Venkat-polagani7 commented 2 months ago

Hello @khoren93,

I have an issue encountering recently in this package when uploading the images from the ReaderWidget. When I continuously uploads the images from the gallery consequently 10~15 times, the app is being crashed and throwing the errors as shown below:

E/AndroidRuntime(13388): FATAL EXCEPTION: pool-109-thread-1
E/AndroidRuntime(13388): Process: com.example.projectCamera, PID: 13388
E/AndroidRuntime(13388): java.lang.IllegalArgumentException: Each request must have at least one Surface target
E/AndroidRuntime(13388):    at android.hardware.camera2.impl.CameraDeviceImpl.submitCaptureRequest(CameraDeviceImpl.java:1293)
E/AndroidRuntime(13388):    at android.hardware.camera2.impl.CameraDeviceImpl.setRepeatingRequest(CameraDeviceImpl.java:1369)
E/AndroidRuntime(13388):    at android.hardware.camera2.impl.CameraCaptureSessionImpl.setRepeatingRequest(CameraCaptureSessionImpl.java:332)
E/AndroidRuntime(13388):    at io.flutter.plugins.camera.Camera.refreshPreviewCaptureSession(Camera.java:587)
E/AndroidRuntime(13388):    at io.flutter.plugins.camera.Camera$2.onConfigured(Camera.java:518)
E/AndroidRuntime(13388):    at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.lambda$onConfigured$0(CallbackProxies.java:53)
E/AndroidRuntime(13388):    at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.$r8$lambda$XOBHWVfryPuKTX27fDYaiDBtLvc(Unknown Source:0)
E/AndroidRuntime(13388):    at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy$$ExternalSyntheticLambda6.run(Unknown Source:4)
E/AndroidRuntime(13388):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/AndroidRuntime(13388):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/AndroidRuntime(13388):    at java.lang.Thread.run(Thread.java:1012)

There was some information about this error in the CameraDeviceImp code, here is the link to it.


// Make sure that there all requests have at least 1 surface; all surfaces are non-null;
for (CaptureRequest request : requestList) {
   if (request.getTargets().isEmpty()) {
     throw new IllegalArgumentException(
     "Each request must have at least one Surface target");
   }
  
   for (Surface surface : request.getTargets()) {
     if (surface == null) {
         throw new IllegalArgumentException("Null Surface targets are not allowed");
     }
   }   
}
 

@khoren93 Could you please help me in resolving this issue ? or any suggestions to avoid this issue also appreciated.

Thanks