triniwiz / fancycamera

MIT License
8 stars 13 forks source link

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

Closed kriefsacha closed 3 years ago

kriefsacha commented 3 years ago

Hi,

Im adressing to you here about this ticket.

Im using nativescript-camera-plus plugin who use the last version of your plugin.

In our app we need to take multiple pictures (we take a picture, then close the plugin (with an ngIf if you know angular) and then open it again.. so the camera is disposed every time, we see the "NativeScript-CameraPlus --- [disposeNativeView.]" console log), and after 128 times we have this android error with this stacktrace:

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

Seems like we reached an android limit amount of listeners.

As you can see at the end, this seems to be related to this plugin. I assume that there is a listener which you don't do "unregister" when the camera is diposed. When im searching about it i see about Sensors things. But i can't manage to unregister them because i don't have the instance of your listeners.

This a very big issue for us so if you could help, i already opened the previous ticket since a couple of days..

Thank you !

kriefsacha commented 3 years ago

@triniwiz can you please help us on that ?

It's a big issue for us and we think just by doing unregister of the listeners (seems likely of the orientation one) when the camera is disposed will resolved that.

Thank you..

kriefsacha commented 3 years ago

Still no news of this... @triniwiz this is a very big problem..

You just need to unregister the listeners when you dispose the camera please..

kriefsacha commented 3 years ago

@triniwiz could you please answer..

kriefsacha commented 3 years ago

Not any answer here @triniwiz .. we are willing to pay if needed please help you just need to unregister the listeners on camera disposed..

triniwiz commented 3 years ago

This should fixed now