Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
359 views
in Technique[技术] by (71.8m points)

android - Nativescript Angular - java.lang.IllegalStateException: register failed, the sensor listeners size has exceeded the maximum limit 128

I'm working on Nativescript angular (v6.5.1).

I'm showing an embedded camera with the plugin @nstudio/nativescript-camera-plus who use himself the plugin FancyCamera for the camera on android. The thing is, when you show/hide/show the plugin 128 times (i need it for my project), you have an android exception:

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

As you can see, this comes from the FancyCamera plugin. He puted listeners to android sensors orientation and is not unregistering it when the camera is disposed. I tried to restart the app after 100 times with this code as a workaround:

const activity: androidx.appcompat.app.AppCompatActivity = and.foregroundActivity;
const intent: android.content.Intent = activity.getIntent();

activity.finish();
and.context.startActivity(intent);

But when the app restarts, the camera doesn't show and the loaded event doesn't pop up.

I opened one ticket on nativescript-camera-plus and one on fancycamera but no one is answering.

I also can't unregister the listeners myself because i don't have the instances, and i can't modify the fancycamera in the node modules because i don't have it there, i only have nativescript-camera-plus who is himself importing it...

So i'm stuck since like more then a week, without any workaround, didn't found another nativescript plugin for embedded camera in a page..

If you could help me please.

My package.json:

{
  "nativescript": {
    "id": "org.nativescript.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 !


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...