RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.81k stars 405 forks source link

ConcurrentModificationException #310

Closed masterwok closed 5 years ago

masterwok commented 5 years ago

Stack Trace

    Process: com.masterwok.simplebarcodescannerfree, PID: 30406
    java.util.ConcurrentModificationException
        at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:966)
        at java.util.LinkedList$ListItr.next(LinkedList.java:888)
        at kotlin.collections.CollectionsKt__MutableCollectionsKt.filterInPlace$CollectionsKt__MutableCollectionsKt(MutableCollections.kt:164)
        at kotlin.collections.CollectionsKt__MutableCollectionsKt.filterInPlace$CollectionsKt__MutableCollectionsKt(MutableCollections.kt:184)
        at kotlin.collections.CollectionsKt__MutableCollectionsKt.removeAll(MutableCollections.kt:175)
        at io.fotoapparat.concurrent.CameraExecutor.cleanUpCancelledTasks(CameraExecutor.kt:39)
        at io.fotoapparat.concurrent.CameraExecutor.execute(CameraExecutor.kt:33)
        at io.fotoapparat.routine.orientation.StartOrientationRoutineKt$startOrientationMonitoring$1.invoke(StartOrientationRoutine.kt:15)
        at io.fotoapparat.routine.orientation.StartOrientationRoutineKt$startOrientationMonitoring$1.invoke(Unknown Source:2)
        at io.fotoapparat.hardware.orientation.OrientationSensor$onOrientationChanged$1.invoke(OrientationSensor.kt:27)
        at io.fotoapparat.hardware.orientation.OrientationSensor$onOrientationChanged$1.invoke(OrientationSensor.kt:11)
        at io.fotoapparat.hardware.orientation.RotationListener.onOrientationChanged(RotationListener.kt:18)
        at android.view.OrientationEventListener$SensorEventListenerImpl.onSensorChanged(OrientationEventListener.java:143)
        at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:889)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:325)
        at android.os.Looper.loop(Looper.java:142)
        at android.app.ActivityThread.main(ActivityThread.java:6753)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

What are you trying to achieve or the steps to reproduce?

Very difficult to reproduce, crash has only occurred once over the course of many days of development.

    val barcodeScanObservable: Observable<BarcodeScanResult> = Observable
            .interval(CameraInterval, TimeUnit.MILLISECONDS)
            .takeWhile { cameraIsReady }
            .flatMapSingle { takePicture() }
            .flatMapSingle { bitmapPhoto -> detectBarcodes(bitmapPhoto.bitmap) }

    private fun takePicture() = fotoapparat!!
            .takePicture()
            .toBitmap()
            .toSingle()

How did you initialize FA?

    private fun configureCamera(): Fotoapparat = Fotoapparat
            .with(requireContext())
            .into(cameraView)
            .focusMode { FocusMode.ContinuousFocusPicture }
            .flash { Flash.Torch }
            .lensPosition { LensPosition.Back }
            .photoResolution { Resolution(PhotoResolutionWidth, PhotoResolutionHeight) }
            .build()
            .apply {
                start()
            }

What was the result you received?

Crash

What did you expect?

No crash

Context: