enioka-Haute-Couture / enioka_scan

Integration library for all your Android hardware barcode scanner integration needs
Apache License 2.0
52 stars 4 forks source link

Plantage lorsque j'essai de quitter une Activity / Camera 2 #149

Closed fmanoir closed 10 months ago

fmanoir commented 10 months ago

Bonjour,

Bonjour @DaSpood, @marcanpilami ,

Lorsque nous exécutons par fois un scan en utilisant la librairie au sein de notre application, notamment sur les appareils Xcover 4S et 5, nous rencontrons un problème d'instabilité qui conduit à un crash de l'application. Voici les traces que j'ai pu récupérer suite à l'arrêt inattendu de l'application :

a36

Emplacement de Plantage

le crache se produit dans super.onpause()

                Log.d(TAG, "Setting AF mode to " + controlModeAf);
                captureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, controlModeAf);
            }

Log

2024-01-10 15:14:21.737 21832-21832 ViewRootIm...nActivity] com.geodis.mobiprep                  I  applyTransactionOnDraw: mRemoved = false isHardwareEnabled = true t = 0xb400006f4d0c4700android.view.SurfaceView.applyTransactionOnVriDraw:2048 android.view.SurfaceView.performSurfaceTransaction:959 android.view.SurfaceView.updateSurface:1105 android.view.SurfaceView.setWindowStopped:335 android.view.SurfaceView.surfaceCreated:1853 
2024-01-10 15:14:21.737 21832-21832 SurfaceView@fdb2760     com.geodis.mobiprep                  I  updateSurface: mVisible = true mSurface.isValid() = true
2024-01-10 15:14:21.737 21832-21832 SurfaceView@fdb2760     com.geodis.mobiprep                  I  updateSurface: mSurfaceCreated = false surfaceChanged = true visibleChanged = true
2024-01-10 15:14:21.737 21832-21832 SurfaceView@fdb2760     com.geodis.mobiprep                  I  visibleChanged -- surfaceCreated
2024-01-10 15:14:21.737 21832-21832 SurfaceView@fdb2760     com.geodis.mobiprep                  I  surfaceCreated 1 #1 com.enioka.scanner.camera.CameraPreviewSurfaceView{fdb2760 V.E...... ........ 0,0-720,1208}
2024-01-10 15:14:21.737 21832-21832 BARCODE                 com.geodis.mobiprep                  D  Preview surface created, camera will be initialized soon 177157145
2024-01-10 15:14:21.740 21832-21832 BARCODE                 com.geodis.mobiprep                  D  INFO_SUPPORTED_HARDWARE_LEVEL LIMITED
2024-01-10 15:14:21.740 21832-21832 BARCODE                 com.geodis.mobiprep                  I  Camera supports flash: true
2024-01-10 15:14:21.740 21832-21832 BARCODE                 com.geodis.mobiprep                  D  Reusing previously chosen resolution
2024-01-10 15:14:21.740 21832-21832 BARCODE                 com.geodis.mobiprep                  I  Camera uses preview resolution: 1920*1080
2024-01-10 15:14:21.740 21832-21832 BARCODE                 com.geodis.mobiprep                  D  Supported FPS ranges:
2024-01-10 15:14:21.740 21832-21832 BARCODE                 com.geodis.mobiprep                  D      15,15
2024-01-10 15:14:21.740 21832-21832 BARCODE                 com.geodis.mobiprep                  D      15,20
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  D      20,20
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  D      24,24
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  D      8,30
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  D      10,30
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  D      15,30
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  D      30,30
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  I  Requesting preview FPS range at 30,30
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  I  Camera uses FPS range: [30, 30]
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  I  Using AF mode: CONTROL_AF_MODE_CONTINUOUS_PICTURE
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  I  Supported autofocus zones: 1
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  I  Using AB mode: CONTROL_AE_ANTIBANDING_MODE_AUTO
2024-01-10 15:14:21.741 21832-21832 BARCODE                 com.geodis.mobiprep                  I  Selected camera id: 0
2024-01-10 15:14:21.741 21832-21832 CameraManagerGlobal     com.geodis.mobiprep                  I  postSingleTorchUpdate device: camera id 0 status 1
2024-01-10 15:14:21.742 21832-21832 SurfaceView@fdb2760     com.geodis.mobiprep                  I  surfaceChanged -- format=4 w=1920 h=1080
2024-01-10 15:14:21.742 21832-21832 SurfaceView@fdb2760     com.geodis.mobiprep                  I  surfaceChanged (1920,1080) 1 #1 com.enioka.scanner.camera.CameraPreviewSurfaceView{fdb2760 V.E...... ........ 0,0-720,1208}
2024-01-10 15:14:21.742 21832-21832 BARCODE                 com.geodis.mobiprep                  I  surface changed 177157145
2024-01-10 15:14:21.742 21832-21832 SurfaceView@fdb2760     com.geodis.mobiprep                  I  surfaceRedrawNeeded
2024-01-10 15:14:21.743 21832-21832 SurfaceView@fdb2760     com.geodis.mobiprep                  V  Layout: x=0 y=170 w=720 h=1208, frame=Rect(0, 0 - 1920, 1080)
2024-01-10 15:14:21.743 21832-21832 ViewRootIm...nActivity] com.geodis.mobiprep                  I  reportNextDraw android.view.ViewRootImpl.performTraversals:4438 android.view.ViewRootImpl.doTraversal:3116 android.view.ViewRootImpl$TraversalRunnable.run:10885 android.view.Choreographer$CallbackRecord.run:1301 android.view.Choreographer$CallbackRecord.run:1309 
2024-01-10 15:14:21.743 21832-21832 ViewRootIm...nActivity] com.geodis.mobiprep                  I  Setup new sync id=2
2024-01-10 15:14:21.743 21832-21832 ViewRootIm...nActivity] com.geodis.mobiprep                  I  Setting syncFrameCallback
2024-01-10 15:14:21.743 21832-21832 SurfaceSyncer           com.geodis.mobiprep                  E  Failed to find sync for id=0
2024-01-10 15:14:21.743 21832-21832 SurfaceSyncer           com.geodis.mobiprep                  E  Failed to find sync for id=1
2024-01-10 15:14:21.743 21832-21832 SurfaceSyncer           com.geodis.mobiprep                  E  Failed to find sync for id=2
2024-01-10 15:14:21.743 21832-21832 SurfaceSyncer           com.geodis.mobiprep                  E  Failed to find sync for id=3
2024-01-10 15:14:21.743 21832-21832 ViewRootIm...nActivity] com.geodis.mobiprep                  I  registerCallbacksForSync syncBuffer=false
2024-01-10 15:14:21.748 21832-21970 SurfaceView@fdb2760     com.geodis.mobiprep                  D  updateSurfacePosition RenderWorker, frameNr = 1, position = [0, 170, 720, 1378] surfaceSize = 1920x1080
2024-01-10 15:14:21.748 21832-21970 SurfaceView@fdb2760     com.geodis.mobiprep                  I  uSP: rtp = Rect(0, 170 - 720, 1378) rtsw = 1920 rtsh = 1080
2024-01-10 15:14:21.748 21832-21970 SurfaceView@fdb2760     com.geodis.mobiprep                  I  onSSPAndSRT: pl = 0 pt = 170 sx = 0.375 sy = 1.1185185
2024-01-10 15:14:21.748 21832-21970 SurfaceView@fdb2760     com.geodis.mobiprep                  I  aOrMT: ViewRootImpl@6a11818[ScanTokenActivity] t = android.view.SurfaceControl$Transaction@f807f20 fN = 1 android.view.SurfaceView.-$$Nest$mapplyOrMergeTransaction:0 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1537 android.graphics.RenderNode$CompositePositionUpdateListener.positionChanged:373 
2024-01-10 15:14:21.748 21832-21970 ViewRootIm...nActivity] com.geodis.mobiprep                  I  mWNT: t=0xb400006f4d0c4a00 mBlastBufferQueue=0xb400006ee732c900 fn= 1 caller= android.view.SurfaceView.applyOrMergeTransaction:1455 android.view.SurfaceView.-$$Nest$mapplyOrMergeTransaction:0 android.view.SurfaceView$SurfaceViewPositionUpdateListener.positionChanged:1537 
2024-01-10 15:14:21.748 21832-21970 ViewRootIm...nActivity] com.geodis.mobiprep                  I  mWNT: t=0xb400006ee36a5e00 mBlastBufferQueue=0xb400006ee732c900 fn= 1 caller= android.view.ViewRootImpl.lambda$applyTransactionOnDraw$11$android-view-ViewRootImpl:12865 android.view.ViewRootImpl$$ExternalSyntheticLambda1.onFrameDraw:4 android.graphics.HardwareRenderer$FrameDrawingCallback.onFrameDraw:924 
2024-01-10 15:14:21.748 21832-21970 ViewRootIm...nActivity] com.geodis.mobiprep                  I  mWNT: t=0xb400006f4d0c4700 mBlastBufferQueue=0xb400006ee732c900 fn= 1 caller= android.view.ViewRootImpl.lambda$applyTransactionOnDraw$11$android-view-ViewRootImpl:12865 android.view.ViewRootImpl$$ExternalSyntheticLambda1.onFrameDraw:4 android.graphics.HardwareRenderer$FrameDrawingCallback.onFrameDraw:924 
2024-01-10 15:14:21.749 21832-21970 ViewRootIm...nActivity] com.geodis.mobiprep                  I  Received frameDrawingCallback syncResult=0 frameNum=1.
2024-01-10 15:14:21.749 21832-21970 ViewRootIm...nActivity] com.geodis.mobiprep                  I  Setting up sync and frameCommitCallback
2024-01-10 15:14:21.753 21832-21873 BLASTBufferQueue        com.geodis.mobiprep                  I  [ViewRootImpl@6a11818[ScanTokenActivity]#23](f:0,a:0) onFrameAvailable the first frame is available
2024-01-10 15:14:21.755 21832-21873 ViewRootIm...nActivity] com.geodis.mobiprep                  I  Received frameCommittedCallback lastAttemptedDrawFrameNum=1 didProduceBuffer=true
2024-01-10 15:14:21.756 21832-21832 ViewRootIm...nActivity] com.geodis.mobiprep                  I  onSyncComplete
2024-01-10 15:14:21.756 21832-21832 ViewRootIm...nActivity] com.geodis.mobiprep                  I  setupSync seqId=0 mSyncId=2 fn=1 caller=android.view.ViewRootImpl$$ExternalSyntheticLambda11.accept:6 android.window.SurfaceSyncer.lambda$setupSync$1$android-window-SurfaceSyncer:128 android.window.SurfaceSyncer$$ExternalSyntheticLambda1.accept:8 android.window.SurfaceSyncer$SyncSet.checkIfSyncIsComplete:382 android.window.SurfaceSyncer$SyncSet.markSyncReady:359 android.window.SurfaceSyncer.markSyncReady:151 android.view.ViewRootImpl.performTraversals:4503 
2024-01-10 15:14:21.757 21832-21832 ViewRootIm...nActivity] com.geodis.mobiprep                  I  reportDrawFinished seqId=0 mSyncId=-1 fn=1 mSurfaceChangedTransaction=0xb400006f4d246800
2024-01-10 15:14:21.757 21832-21832 ScanTokenActivity       com.geodis.mobiprep                  D  Status changed: CONNECTED --- Scanner connecté
2024-01-10 15:14:21.757 21832-21832 BARCODE                 com.geodis.mobiprep                  W  setTorchInternal: No captureSession instance, make sure camera was properly initialized and `pauseCamera()` or `closeCamera()` were not called previously
2024-01-10 15:14:21.761 21832-21832 JustificationClient     com.geodis.mobiprep                  I   justification ws query OK
2024-01-10 15:14:21.766 21832-21832 DataStore               com.geodis.mobiprep                  V  store file /data/user/0/com.geodis.mobiprep/app_state/justification
2024-01-10 15:14:21.767 21832-21832 JourneyManager          com.geodis.mobiprep                  I  buildIndexConsignmentsPreparations
2024-01-10 15:14:21.771 21832-21832 DataStore               com.geodis.mobiprep                  V  store file /data/user/0/com.geodis.mobiprep/app_state/preparation
2024-01-10 15:14:21.812 21832-21832 CameraManagerGlobal     com.geodis.mobiprep                  I  onTorchModeChanged
2024-01-10 15:14:21.812 21832-21832 BARCODE                 com.geodis.mobiprep                  D  Torch status has changed to: false
2024-01-10 15:14:21.813 21832-21832 BARCODE                 com.geodis.mobiprep                  D  Trying to open camera from CameraManager 177157145
2024-01-10 15:14:21.813 21832-21832 BARCODE                 com.geodis.mobiprep                  D  Starting background thread handler 177157145
2024-01-10 15:14:21.825 21832-21853 CameraManagerGlobal     com.geodis.mobiprep                  I  postSingleTorchUpdate device: camera id 0 status 0
2024-01-10 15:14:21.826 21832-21853 CameraManagerGlobal     com.geodis.mobiprep                  I  postSingleTorchUpdate device: camera id 0 status 0
2024-01-10 15:14:21.826 21832-21853 CameraManagerGlobal     com.geodis.mobiprep                  I  postSingleTorchUpdate device: camera id 0 status 0
2024-01-10 15:14:21.826 21832-21853 CameraManagerGlobal     com.geodis.mobiprep                  I  postSingleTorchUpdate device: camera id 0 status 0
2024-01-10 15:14:21.844 21832-21853 CameraManagerGlobal     com.geodis.mobiprep                  I  Camera 0 facing CAMERA_FACING_BACK state now CAMERA_STATE_OPEN for client com.geodis.mobiprep API Level 2User Id 0
2024-01-10 15:14:21.844 21832-21832 BARCODE                 com.geodis.mobiprep                  D  Camera device not ready yet
2024-01-10 15:14:21.844 21832-21832 SurfaceView@fdb2760     com.geodis.mobiprep                  I  finishedDrawing
2024-01-10 15:14:21.844 21832-23918 BARCODE                 com.geodis.mobiprep                  V  CameraDevice.StateCallback.onOpened 177157145
2024-01-10 15:14:21.844 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Initializing or reinitializing preview analysis loop
2024-01-10 15:14:21.845 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Analyser (ZBar) is ready inside pool
2024-01-10 15:14:21.845 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Analyser (ZBar) is ready inside pool
2024-01-10 15:14:21.845 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Analyser (ZBar) is ready inside pool
2024-01-10 15:14:21.846 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Analyser (ZBar) is ready inside pool
2024-01-10 15:14:21.846 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Analyser (ZBar) is ready inside pool
2024-01-10 15:14:21.847 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Analyser (ZBar) is ready inside pool
2024-01-10 15:14:21.848 21832-21832 ScannerActivity         com.geodis.mobiprep                  I  Scanner activity is being paused 244985550
2024-01-10 15:14:21.850 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Analyser (ZBar) is ready inside pool
2024-01-10 15:14:21.851 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Analyser (ZBar) is ready inside pool
2024-01-10 15:14:21.851 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Analyser pool initialized with 8 threads
2024-01-10 15:14:21.852 21832-23918 BARCODE                 com.geodis.mobiprep                  D  Capture session creation begins
2024-01-10 15:14:21.985 21832-23918 BARCODE                 com.geodis.mobiprep                  D  Configuration request sent
2024-01-10 15:14:21.985 21832-23918 BARCODE                 com.geodis.mobiprep                  D  Preview analysis loop start method done
2024-01-10 15:14:21.986 21832-21832 BARCODE                 com.geodis.mobiprep                  D  Starting camera release 177157145
2024-01-10 15:14:21.986 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Capture session is now configured and will start the capture request loop 177157145
2024-01-10 15:14:21.986 21832-21832 BARCODE                 com.geodis.mobiprep                  D   * Closing camera capture session
2024-01-10 15:14:21.987 21832-21832 BARCODE                 com.geodis.mobiprep                  D   * Clearing camera capture builder
2024-01-10 15:14:21.987 21832-23918 BARCODE                 com.geodis.mobiprep                  D  Using metering zone (72,542) (648,664)
2024-01-10 15:14:21.987 21832-21832 BARCODE                 com.geodis.mobiprep                  D   * Camera device closing
2024-01-10 15:14:21.988 21832-23918 BARCODE                 com.geodis.mobiprep                  D  Setting AF mode to 4
--------- beginning of crash
2024-01-10 15:14:21.989 21832-23918 AndroidRuntime          com.geodis.mobiprep                  E  FATAL EXCEPTION: CameraBackground
                                                                                                    Process: com.geodis.mobiprep, PID: 21832
                                                                                                    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.hardware.camera2.CaptureRequest$Builder.set(android.hardware.camera2.CaptureRequest$Key, java.lang.Object)' on a null object reference
                                                                                                        at com.enioka.scanner.camera.CameraBarcodeScanViewV2$4.onConfigured(CameraBarcodeScanViewV2.java:734)
                                                                                                        at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.lambda$onConfigured$0$android-hardware-camera2-impl-CallbackProxies$SessionStateCallbackProxy(CallbackProxies.java:53)
                                                                                                        at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy$$ExternalSyntheticLambda6.run(Unknown Source:4)
                                                                                                        at android.os.Handler.handleCallback(Handler.java:942)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                                                        at android.os.Looper.loopOnce(Looper.java:226)
                                                                                                        at android.os.Looper.loop(Looper.java:313)
                                                                                                        at android.os.HandlerThread.run(HandlerThread.java:67)
2024-01-10 15:14:22.001 21832-23918 Process                 com.geodis.mobiprep                  I  Sending signal. PID: 21832 SIG: 9
2024-01-10 15:14:22.147  1172-1226  WindowManager           system_server                        E  win=Window{9b3c1e6 u0 com.geodis.mobiprep/com.geodis.mobiprep.PreDebriefActivity EXITING} destroySurfaces: appStopped=false cleanupOnResume=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.ActivityRecord.destroySurfaces:6539 com.android.server.wm.ActivityRecord.destroySurfaces:6520 com.android.server.wm.WindowState.onExitAnimationDone:5989 com.android.server.wm.ActivityRecord$$ExternalSyntheticLambda10.accept:2 java.util.ArrayList.forEach:1528 com.android.server.wm.ActivityRecord.onAnimationFinished:8607 com.android.server.wm.WindowContainer$$ExternalSyntheticLambda4.onAnimationFinished:2 
2024-01-10 15:14:22.157  1172-1226  WindowManager           system_server                        E  win=Window{ee6a50a u0 com.geodis.mobiprep/com.geodis.mobiprep.ScanTokenActivity EXITING} destroySurfaces: appStopped=false cleanupOnResume=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.ActivityRecord.destroySurfaces:6539 com.android.server.wm.ActivityRecord.destroySurfaces:6520 com.android.server.wm.WindowState.onExitAnimationDone:5989 com.android.server.wm.ActivityRecord$$ExternalSyntheticLambda10.accept:2 java.util.ArrayList.forEach:1528 com.android.server.wm.ActivityRecord.onAnimationFinished:8607 com.android.server.wm.WindowContainer$$ExternalSyntheticLambda4.onAnimationFinished:2 
---------------------------- PROCESS STARTED (23965) for package com.geodis.mobiprep ----------------------------
---------------------------- PROCESS ENDED (21832) for package com.geodis.mobiprep ----------------------------
2024-01-10 15:14:23.022 23965-23990 BLASTBufferQueue        com.geodis.mobiprep                  I  [ViewRootImpl@10a3b46[MainLoadingActivity]#0](f:0,a:0) onFrameAvailable the first frame is available
2024-01-10 15:14:23.023 23965-23990 ViewRootIm...gActivity] com.geodis.mobiprep                  I  Received frameCommittedCallback lastAttemptedDrawFrameNum=1 didProduceBuffer=true
2024-01-10 15:14:23.024 23965-23990 OpenGLRenderer          com.geodis.mobiprep                  D  CFMS:: SetUp Pid : 23965    Tid : 23990
2024-01-10 15:14:23.029 23965-23965 ViewRootIm...gActivity] com.geodis.mobiprep                  I  onSyncComplete
2024-01-10 15:14:23.030 23965-23965 ViewRootIm...gActivity] com.geodis.mobiprep                  I  setupSync seqId=0 mSyncId=0 fn=1 caller=android.view.ViewRootImpl$$ExternalSyntheticLambda11.accept:6 android.window.SurfaceSyncer.lambda$setupSync$1$android-window-SurfaceSyncer:128 android.window.SurfaceSyncer$$ExternalSyntheticLambda1.accept:8 android.window.SurfaceSyncer$SyncSet.checkIfSyncIsComplete:382 android.window.SurfaceSyncer$SyncSet.markSyncReady:359 android.window.SurfaceSyncer.markSyncReady:151 android.view.ViewRootImpl.performTraversals:4503 
2024-01-10 15:14:23.030 23965-23965 ViewRootIm...gActivity] com.geodis.mobiprep                  I  reportDrawFinished seqId=0 mSyncId=-1 fn=1 mSurfaceChangedTransaction=0xb400006f4397eb00
2024-01-10 15:14:23.059 23965-23965 ScannerActivity         com.geodis.mobiprep                  I  Scanner activity is being destroyed 51940275
2024-01-10 15:14:23.061 23965-23965 ScannerActivity         com.geodis.mobiprep                  I  Scanner activity is being stopped 119422130
2024-01-10 15:14:23.062 23965-23965 ScannerActivity         com.geodis.mobiprep                  I  Scanner activity is being destroyed 119422130
2024-01-10 15:14:23.062 23965-23965 ViewRootIm...gActivity] com.geodis.mobiprep                  I  MSG_WINDOW_FOCUS_CHANGED 1 0
2024-01-10 15:14:23.063 23965-23965 ViewRootIm...gActivity] com.geodis.mobiprep                  I  mThreadedRenderer.initializeIfNeeded()#2 mSurface={isValid=true 0xb400006ef4fa2800}
2024-01-10 15:14:23.065 23965-23965 InputMethodManager      com.geodis.mobiprep                  D  startInputInner - Id : 0
2024-01-10 15:14:23.065 23965-23965 InputMethodManager      com.geodis.mobiprep                  I  startInputInner - mService.startInputOrWindowGainedFocus
2024-01-10 15:14:23.088 23965-23965 InputMethodManager      com.geodis.mobiprep                  D  startInputInner - Id : 0
2024-01-10 15:14:52.515 23965-23975 geodis.mobiprep         com.geodis.mobiprep                  W  Cleared Reference was only reachable from finalizer (only reported once)
DaSpood commented 10 months ago

D’après les logs, il semblerait que le callback onConfigured() de la CaptureSession est appelée en parallèle de (ou après) un appel a closeCamera() et fait donc appel a une classe qui n'est plus instanciée.

Y a-t-il un scenario ou une suite d’opérations typique qui permette de reproduire régulièrement ce crash ?

fmanoir commented 10 months ago

Oui, pour le scenario, je pense

Activity A (ScannerCompatActivity) -> Activity B -> Activity A (ScannerCompatActivity) juste pour valider un traitement puis ->Activity C

peut être super.onResume(); lance onConfigured et super.onPause(); lance closeCamera()

J'essai même de mettre un try/catch dans notre onPause pour skipper l'exception mais ça fonctionne plus

DaSpood commented 10 months ago

D’après les logs il semble que le passage sur la ScannerCompatActivity soit très rapide au point que l'appel a onPause() se produit avant la fin de l'initialisation de la camera qui suit le onResume() et continue en parallèle:

2024-01-10 15:14:21.985 21832-23918 BARCODE                 com.geodis.mobiprep                  D  Configuration request sent ==> `startPreview()`
2024-01-10 15:14:21.985 21832-23918 BARCODE                 com.geodis.mobiprep                  D  Preview analysis loop start method done ==> `startPreview()`
2024-01-10 15:14:21.986 21832-21832 BARCODE                 com.geodis.mobiprep                  D  Starting camera release 177157145 ==> `closeCamera()`
2024-01-10 15:14:21.986 21832-23918 BARCODE                 com.geodis.mobiprep                  I  Capture session is now configured and will start the capture request loop 177157145 ==> `onConfigured()`
2024-01-10 15:14:21.986 21832-21832 BARCODE                 com.geodis.mobiprep                  D   * Closing camera capture session ==> `closeCamera()`
2024-01-10 15:14:21.987 21832-21832 BARCODE                 com.geodis.mobiprep                  D   * Clearing camera capture builder ==> `closeCamera()`
2024-01-10 15:14:21.987 21832-23918 BARCODE                 com.geodis.mobiprep                  D  Using metering zone (72,542) (648,664) ==> `onConfigured()`
2024-01-10 15:14:21.987 21832-21832 BARCODE                 com.geodis.mobiprep                  D   * Camera device closing ==> `closeCamera()`
2024-01-10 15:14:21.988 21832-23918 BARCODE                 com.geodis.mobiprep                  D  Setting AF mode to 4 ==> `onConfigured()`

Les deux derniers logs de la fonction onConfigured() effectuent le meme appel de fonction sur la meme variable, mais seul le deuxième cause l'erreur car la variable est mise a null entre temps, donc closeCamera() se déroule bien en parallèle de onConfigured().

La seule solution de notre coté serait d'englober onConfigured() dans un grand try/catch. Alternativement, serait-il possible de ralentir de quelques millisecondes le changement d’activité afin d'attendre la fin de son initialisation ?

fmanoir commented 10 months ago

Ok, j'essaie de faire ça, mais, ceci n'est pas lié aussi au souci de #150 ; le onConfigured() mal fonctionne dans deux appel consécutive

fmanoir commented 10 months ago

Re,

Possible de publier une MAJ avec l'englober onConfigured() dans un grand try/catch ?

DaSpood commented 10 months ago

C'est possible, je m'occupe de ca demain apres-midi

DaSpood commented 10 months ago

Le fix est disponible dans la version 2.4.2, qui sera disponible sur maven central sous peu.

fmanoir commented 10 months ago

Merci fonctionne parfaitement