Apparence-io / CamerAwesome

šŸ“ø Embedding a camera experience within your own app shouldn't be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.
https://ApparenceKit.dev
MIT License
976 stars 256 forks source link

Error while switching the camera #20

Closed melwinlobo18 closed 4 years ago

melwinlobo18 commented 4 years ago

Steps to Reproduce

Click on Switch Camera option in the camera_awesome example project.

Expected results

Front Camera should be shown

Actual results

Screen Freezes with the following error

W/awesome_example(23049): type=1400 audit(0.0:496973): avc: denied { read } for name="u:object_r:camera_prop:s0" dev="tmpfs" ino=16448 scontext=u:r:untrusted_app:s0:c45,c258,c512,c768 tcontext=u:object_r:camera_prop:s0 tclass=file permissive=0
E/libc    (23049): Access denied finding property "camera.aux.packagelist"
W/Binder:23049_9(23049): type=1400 audit(0.0:496976): avc: denied { read } for name="u:object_r:camera_prop:s0" dev="tmpfs" ino=16448 scontext=u:r:untrusted_app:s0:c45,c258,c512,c768 tcontext=u:object_r:camera_prop:s0 tclass=file permissive=0
E/libc    (23049): Access denied finding property "camera.aux.packagelist"
W/Binder:23049_9(23049): type=1400 audit(0.0:496977): avc: denied { read } for name="u:object_r:camera_prop:s0" dev="tmpfs" ino=16448 scontext=u:r:untrusted_app:s0:c45,c258,c512,c768 tcontext=u:object_r:camera_prop:s0 tclass=file permissive=0
E/libc    (23049): Access denied finding property "camera.aux.packagelist"
E/libc    (23049): Access denied finding property "persist.vendor.camera.privapp.list"
W/awesome_example(23049): type=1400 audit(0.0:496978): avc: denied { read } for name="u:object_r:persist_camera_prop:s0" dev="tmpfs" ino=16561 scontext=u:r:untrusted_app:s0:c45,c258,c512,c768 tcontext=u:object_r:persist_camera_prop:s0 tclass=file permissive=0
E/libc    (23049): Access denied finding property "camera.aux.packagelist"
E/libc    (23049): Access denied finding property "camera.aux.packagelist"
E/libc    (23049): Access denied finding property "camera.aux.packagelist"
E/MethodChannel#camerawesome(23049): Failed to handle method call
E/MethodChannel#camerawesome(23049): java.lang.IllegalStateException: Session has been closed; further changes are illegal.
E/MethodChannel#camerawesome(23049):    at android.hardware.camera2.impl.CameraCaptureSessionImpl.checkNotClosed(CameraCaptureSessionImpl.java:835)
E/MethodChannel#camerawesome(23049):    at android.hardware.camera2.impl.CameraCaptureSessionImpl.abortCaptures(CameraCaptureSessionImpl.java:416)
E/MethodChannel#camerawesome(23049):    at com.apparence.camerawesome.CameraSession.addPictureSurface(CameraSession.java:83)
E/MethodChannel#camerawesome(23049):    at com.apparence.camerawesome.CameraPicture.refresh(CameraPicture.java:74)
E/MethodChannel#camerawesome(23049):    at com.apparence.camerawesome.CameraStateManager.switchCamera(CameraStateManager.java:87)
E/MethodChannel#camerawesome(23049):    at com.apparence.camerawesome.CamerawesomePlugin._handleSwitchSensor(CamerawesomePlugin.java:246)
E/MethodChannel#camerawesome(23049):    at com.apparence.camerawesome.CamerawesomePlugin.onMethodCall(CamerawesomePlugin.java:118)
E/MethodChannel#camerawesome(23049):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#camerawesome(23049):    at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#camerawesome(23049):    at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/MethodChannel#camerawesome(23049):    at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#camerawesome(23049):    at android.os.MessageQueue.next(MessageQueue.java:336)
E/MethodChannel#camerawesome(23049):    at android.os.Looper.loop(Looper.java:181)
E/MethodChannel#camerawesome(23049):    at android.app.ActivityThread.main(ActivityThread.java:7520)
E/MethodChannel#camerawesome(23049):    at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#camerawesome(23049):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/MethodChannel#camerawesome(23049):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
E/CameraCaptureSession(23049): Session 0: Exception while stopping repeating: 
E/CameraCaptureSession(23049): android.hardware.camera2.CameraAccessException: CAMERA_DISCONNECTED (2): checkPidStatus:2087: The camera device has been disconnected
E/CameraCaptureSession(23049):  at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:804)
E/CameraCaptureSession(23049):  at android.hardware.camera2.impl.ICameraDeviceUserWrapper.cancelRequest(ICameraDeviceUserWrapper.java:97)
E/CameraCaptureSession(23049):  at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:1159)
E/CameraCaptureSession(23049):  at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:527)
E/CameraCaptureSession(23049):  at android.hardware.camera2.impl.CameraCaptureSessionImpl$2.onDisconnected(CameraCaptureSessionImpl.java:738)
E/CameraCaptureSession(23049):  at android.hardware.camera2.impl.CameraDeviceImpl$7.run(CameraDeviceImpl.java:245)
E/CameraCaptureSession(23049):  at android.os.Handler.handleCallback(Handler.java:883)
E/CameraCaptureSession(23049):  at android.os.Handler.dispatchMessage(Handler.java:100)
E/CameraCaptureSession(23049):  at android.os.Looper.loop(Looper.java:224)
E/CameraCaptureSession(23049):  at android.app.ActivityThread.main(ActivityThread.java:7520)
E/CameraCaptureSession(23049):  at java.lang.reflect.Method.invoke(Native Method)
E/CameraCaptureSession(23049):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/CameraCaptureSession(23049):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
E/CameraCaptureSession(23049): Caused by: android.os.ServiceSpecificException: checkPidStatus:2087: The camera device has been disconnected (code 4)
E/CameraCaptureSession(23049):  at android.os.Parcel.createException(Parcel.java:2088)
E/CameraCaptureSession(23049):  at android.os.Parcel.readException(Parcel.java:2042)
E/CameraCaptureSession(23049):  at android.os.Parcel.readException(Parcel.java:1990)
E/CameraCaptureSession(23049):  at android.hardware.camera2.ICameraDeviceUser$Stub$Proxy.cancelRequest(ICameraDeviceUser.java:658)
E/CameraCaptureSession(23049):  at android.hardware.camera2.impl.ICameraDeviceUserWrapper.cancelRequest(ICameraDeviceUserWrapper.java:95)
E/CameraCaptureSession(23049):  ... 11 more
E/com.apparence.camerawesome.CameraStateManager(23049): close camera session: failed
E/flutter (23049): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(error, Session has been closed; further changes are illegal., null, java.lang.IllegalStateException: Session has been closed; further changes are illegal.
E/flutter (23049):  at android.hardware.camera2.impl.CameraCaptureSessionImpl.checkNotClosed(CameraCaptureSessionImpl.java:835)
E/flutter (23049):  at android.hardware.camera2.impl.CameraCaptureSessionImpl.abortCaptures(CameraCaptureSessionImpl.java:416)
E/flutter (23049):  at com.apparence.camerawesome.CameraSession.addPictureSurface(CameraSession.java:83)
E/flutter (23049):  at com.apparence.camerawesome.CameraPicture.refresh(CameraPicture.java:74)
E/flutter (23049):  at com.apparence.camerawesome.CameraStateManager.switchCamera(CameraStateManager.java:87)
E/flutter (23049):  at com.apparence.camerawesome.CamerawesomePlugin._handleSwitchSensor(CamerawesomePlugin.java:246)
E/flutter (23049):  at com.apparence.camerawesome.CamerawesomePlugin.onMethodCall(CamerawesomePlugin.java:118)
E/flutter (23049):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (23049):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter (23049):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
E/flutter (23049):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (23049):  at android.os.MessageQueue.next(MessageQueue.java:336)
E/flutter (23049):  at android.os.Looper.loop(Looper.java:181)
E/flutter (23049):  at android.app.ActivityThread.main(ActivityThread.java:7520)
E/flutter (23049):  at java.lang.reflect.Method.invoke(Native Method)
E/flutter (23049):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/flutter (23049):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
E/flutter (23049): )
E/flutter (23049): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7)
E/flutter (23049): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)
E/flutter (23049): <asynchronous suspension>
E/flutter (23049): #2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
E/flutter (23049): #3      CamerawesomePlugin.setSensor (package:camerawesome/camerawesome_plugin.dart:166:16)
E/flutter (23049): #4      _CameraAwesomeState._initSensor.<anonymous closure> (package:camerawesome/camerapreview.dart:219:32)
E/flutter (23049): #5      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:226:25)
E/flutter (23049): #6      ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:292:5)
E/flutter (23049): #7      _MyAppState._buildTopBar.<anonymous closure> (package:camerawesome_example/main.dart:272:28)
E/flutter (23049): #8      _OptionButtonState.build.<anonymous closure>.<anonymous closure> (package:camerawesome_example/widgets/camera_buttons.dart:118:41)
E/flutter (23049): #9      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
E/flutter (23049): #10     _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:1111:38)
E/flutter (23049): #11     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
E/flutter (23049): #12     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
E/flutter (23049): #13     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
E/flutter (23049): #14     BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:222:7)
E/flutter (23049): #15     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:476:9)
E/flutter (23049): #16     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:77:12)
E/flutter (23049): #17     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter (23049): #18     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter (23049): #19     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter (23049): #20     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter (23049): #21     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:358:19)
E/flutter (23049): #22     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22)
E/flutter (23049): #23     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11)
E/flutter (23049): #24     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart

About your device

Brand Model OS
Xiomi Poco F1 Android 10

Flutter Doctor

[āˆš] Flutter (Channel beta, 1.22.0-12.1.pre, on Microsoft Windows [Version 10.0.18362.1082], locale en-IN)
    ā€¢ Flutter version 1.22.0-12.1.pre at C:\src\flutter
    ā€¢ Framework revision 8b3760638a (12 days ago), 2020-09-15 17:47:13 -0700
    ā€¢ Engine revision 4654fc6cf6
    ā€¢ Dart version 2.10.0 (build 2.10.0-110.3.beta)

[āˆš] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    ā€¢ Android SDK at C:\Users\I524760\AppData\Local\Android\sdk
    ā€¢ Platform android-30, build-tools 30.0.2
    ā€¢ Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    ā€¢ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    ā€¢ All Android licenses accepted.

[āˆš] Chrome - develop for the web
    ā€¢ Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[āˆš] Android Studio (version 4.0)
    ā€¢ Android Studio at C:\Program Files\Android\Android Studio
    ā€¢ Flutter plugin version 48.1.2
    ā€¢ Dart plugin version 193.7547
    ā€¢ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[āˆš] VS Code (version 1.49.0)
    ā€¢ VS Code at C:\Users\I524760\AppData\Local\Programs\Microsoft VS Code
    ā€¢ Flutter extension version 3.14.0

[āˆš] Connected device (4 available)
    ā€¢ POCO F1 (mobile) ā€¢ 3d8cbea1   ā€¢ android-arm64  ā€¢ Android 10 (API 29)
    ā€¢ Web Server (web) ā€¢ web-server ā€¢ web-javascript ā€¢ Flutter Tools
    ā€¢ Chrome (web)     ā€¢ chrome     ā€¢ web-javascript ā€¢ Google Chrome 85.0.4183.121
    ā€¢ Edge (web)       ā€¢ edge       ā€¢ web-javascript ā€¢ Microsoft Edge 85.0.564.51

ā€¢ No issues found!
g-apparence commented 4 years ago

Hello thank you for this issue. Was it in profile mode ? Sometimes camera fail to stop, I'll make an update on the Xiaomi phone to android 10 and make a try. Maybe it's related.

edit : ok I finally reproduced it. I'll investigate

g-apparence commented 4 years ago

Fixed