nstudio / nativescript-camera-plus

MIT License
79 stars 50 forks source link

java.lang.IllegalStateException: register failed, the sensor listeners size has exceeded the maximum limit 128 #147

Closed kriefsacha closed 3 years ago

kriefsacha commented 3 years ago

Hi,

We are using the plugin on nativescript angular (v6.5.1) which works great.

The thing is, we are taking a picture after a few second, hiding the camera, show it again, etc etc.

And after 128 attemps we have this error on android (v11 , multiple different phones):

System.err: An uncaught Exception occurred on "main" thread. System.err: Calling js method onCreateView failed System.err: Error: java.lang.IllegalStateException: register failed, the sensor listeners size has exceeded the maximum limit 128 System.err: System.err: StackTrace: System.err: push.../node_modules/@nstudio/nativescript-camera-plus/camera-plus.js.CameraPlus.createNativeView(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:134859:24) System.err: at push.../node_modules/@nativescript/core/ui/core/view-base/view-base.js.ViewBase._setupUI(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:111229:31) System.err: at (file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:111271:19) System.err: at push.../node_modules/@nativescript/core/ui/layouts/layout-base-common.js.LayoutBaseCommon.eachChildView(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:120475:26) System.err: at push.../node_modules/@nativescript/core/ui/core/view/view-common.js.ViewCommon.eachChild(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:112419:14) System.err: at push.../node_modules/@nativescript/core/ui/core/view-base/view-base.js.ViewBase._setupUI(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:111270:14) System.err: at (file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:111271:19) System.err: at push.../node_modules/@nativescript/core/ui/layouts/layout-base-common.js.LayoutBaseCommon.eachChildView(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:120475:26) System.err: at push.../node_modules/@nativescript/core/ui/core/view/view-common.js.ViewCommon.eachChild(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:112419:14) System.err: at push.../node_modules/@nativescript/core/ui/core/view-base/view-base.js.ViewBase._setupUI(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:111270:14) System.err: at push.../node_modules/@nativescript/core/ui/core/view-base/view-base.js.ViewBase._setupAsRootView(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:111217:14) System.err: at push.../node_modules/@nativescript/core/ui/core/view/view-common.js.ViewCommon._setupAsRootView(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:111704:43) System.err: at DialogFragmentImpl.onCreateView(file:///data/user/0/org.nativescript.VisualyScan/files/app/vendor.js:112852:19) System.err: at com.tns.Runtime.callJSMethodNative(Native Method) System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286) System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1160) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1138) System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1134) System.err: at com.tns.gen.androidx.fragment.app.DialogFragment_vendor_112814_32_DialogFragmentImpl.onCreateView(DialogFragment_vendor_112814_32_DialogFragmentImpl.java:42) System.err: at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600) System.err: at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881) System.err: at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238) System.err: at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303) System.err: at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:439) System.err: at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManagerImpl.java:2079) System.err: at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1869) System.err: at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1824) System.err: at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) System.err: at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150) System.err: at android.os.Handler.handleCallback(Handler.java:938) System.err: at android.os.Handler.dispatchMessage(Handler.java:99) System.err: at android.os.Looper.loop(Looper.java:245) System.err: at android.app.ActivityThread.main(ActivityThread.java:7953) System.err: at java.lang.reflect.Method.invoke(Native Method) System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978) System.err: Caused by: java.lang.IllegalStateException: register failed, the sensor listeners size has exceeded the maximum limit 128 System.err: at android.hardware.SystemSensorManager.registerListenerImpl(SystemSensorManager.java:201) System.err: at android.hardware.SensorManager.registerListener(SensorManager.java:828) System.err: at android.hardware.SensorManager.registerListener(SensorManager.java:735) System.err: at android.view.OrientationEventListener.enable(OrientationEventListener.java:93) System.err: at com.github.triniwiz.fancycamera.CameraBase.(CameraBase.kt:263) System.err: at com.github.triniwiz.fancycamera.Camera2.(Camera2.kt:45) System.err: at com.github.triniwiz.fancycamera.Camera2.(Camera2.kt:44) System.err: at com.github.triniwiz.fancycamera.FancyCamera.init(FancyCamera.kt:179) System.err: at com.github.triniwiz.fancycamera.FancyCamera.(FancyCamera.kt:160) System.err: ... 24 more

I assume this is releated to @triniwiz because as we see at the end it's from the init function.

If you could help us please.

AndroidManifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="__PACKAGE__"
    android:versionCode="20037"
    android:versionName="2.37">

    <supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="true"/>

    <uses-sdk
        android:minSdkVersion="26"
        android:targetSdkVersion="__APILEVEL__"/>

    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"/>

    <uses-feature android:name="android.hardware.camera" android:required="false" />
    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
    <meta-data
    android:name="com.google.firebase.ml.vision.DEPENDENCIES"
    android:value="barcode"/>

    <application
        android:name="com.tns.NativeScriptApplication"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:requestLegacyExternalStorage="true"
        android:largeHeap="true"
        android:theme="@style/AppTheme">

        <activity
            android:name="com.tns.NativeScriptActivity" 
            android:label="@string/title_activity_kimera"
            android:configChanges="keyboardHidden|orientation|screenSize|uiMode" 
            android:theme="@style/LaunchScreenTheme"
            android:screenOrientation="portrait">

            <meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" /> 

            <intent-filter> 
            <action android:name="android.intent.action.MAIN" /> 
            <category android:name="android.intent.category.LAUNCHER" /> 
            </intent-filter> 
        </activity>
        <activity android:name="com.tns.ErrorReportActivity"/>
    </application>
</manifest>

Package.json

{
  "nativescript": {
    "id": "myID",
    "tns-ios": {
      "version": "6.5.2"
    },
    "tns-android": {
      "version": "6.5.3"
    }
  },
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "repository": "<fill-your-repository-here>",
  "dependencies": {
    "@angular/animations": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/http": "8.0.0-beta.10",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "@nativescript/theme": "^3.0.1",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@nstudio/nativescript-camera-plus": "^3.1.1",
    "@nstudio/nativescript-loading-indicator": "^1.0.0",
    "@nstudio/nativescript-pulltorefresh": "^2.0.0",
    "nativescript-angular": "^8.20.4",
    "nativescript-background-http": "^4.2.1",
    "nativescript-camera": "^4.4.0",
    "nativescript-datetimepicker": "^1.2.3",
    "nativescript-imagecropper": "^3.0.0",
    "nativescript-imagepicker": "^7.1.0",
    "nativescript-nfc": "4.0.1",
    "nativescript-permissions": "^1.3.8",
    "nativescript-plugin-firebase": "9.0.2",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-chart": "^7.1.1",
    "nativescript-ui-sidedrawer": "^8.0.1",
    "reflect-metadata": "~0.1.10",
    "rxjs": "^6.4.0",
    "tns-core-modules": "^6.3.2",
    "zone.js": "^0.9.1"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~8.2.0",
    "@nativescript/schematics": "~0.5.0",
    "@ngtools/webpack": "~8.2.0",
    "@types/jasmine": "^3.5.11",
    "nativescript-dev-webpack": "^1.4.1",
    "tns-platform-declarations": "6.0.1",
    "typescript": "~3.5.3"
  },
  "readme": "NativeScript Application"
}

Thank you !

kriefsacha commented 3 years ago

Someone can answer ? @NathanWalker ? This is a very big issue..

kriefsacha commented 3 years ago

Still no response.... Please @NathanWalker help !

kriefsacha commented 3 years ago

Please @NathanWalker @triniwiz .. We need help here i have customers waiting we are willing to pay for the change

triniwiz commented 3 years ago

The latest update should fix this