Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.RuntimeException: TouchThroughTouchHandlerInterface was not set on app activity #5

Open
kristfal opened this issue Jan 7, 2019 · 11 comments

Comments

@kristfal
Copy link

kristfal commented Jan 7, 2019

Hey Simon,

Is this the new "official" repo location? If so, got a crash report. Affects about 0.1% of our users in production. Any thoughts on root cause?

java.lang.RuntimeException: TouchThroughTouchHandlerInterface was not set on app activity

com.rome2rio.android.reactnativetouchthroughview.TouchThroughWrapper.setActivityListener TouchThroughWrapper.java:45
com.rome2rio.android.reactnativetouchthroughview.TouchThroughWrapper.<init> TouchThroughWrapper.java:20
com.rome2rio.android.reactnativetouchthroughview.TouchThroughWrapperManager.createViewInstance TouchThroughWrapperManager.java:18
com.rome2rio.android.reactnativetouchthroughview.TouchThroughWrapperManager.createViewInstance TouchThroughWrapperManager.java:7
com.facebook.react.uimanager.ViewManager.createView ViewManager.java:42
com.facebook.react.uimanager.NativeViewHierarchyManager.createView NativeViewHierarchyManager.java:260
com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute UIViewOperationQueue.java:200
com.facebook.react.uimanager.UIViewOperationQueue$1.run UIViewOperationQueue.java:888
com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches UIViewOperationQueue.java:1001
com.facebook.react.uimanager.UIViewOperationQueue.access$2400 UIViewOperationQueue.java:46
com.facebook.react.uimanager.UIViewOperationQueue$2.runGuarded UIViewOperationQueue.java:959
com.facebook.react.bridge.GuardedRunnable.run GuardedRunnable.java:24
android.os.Handler.handleCallback Handler.java:739
android.os.Handler.dispatchMessage Handler.java:95
android.os.Looper.loop Looper.java:148
android.app.ActivityThread.main ActivityThread.java:5417
java.lang.reflect.Method.invoke Method.java
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run ZygoteInit.java:726
com.android.internal.os.ZygoteInit.main ZygoteInit.java:616
@simonhoss
Copy link
Owner

Hi @kristfal Yes. This will be the new official repo location. I will move everything until next week to this repo.

I did a small research and I can imagine one problem. setActivityListener uses the getCurrentActivity It can be that getCurrentActivity returns null.

Are you able to reproduce the problem with one of your users. If yes, I can add a check here for null to see if this is the problem. If the value is null then we have to figure out why.

@kristfal
Copy link
Author

Hey! Checked this. Read up on:

facebook/react-native#18345

Essentially, we need to do a null guard in Java side and have a retry timer on the JS side for this. The reason is that RN can call into native side when the app is in background, which can cause null activity.

@simonhoss
Copy link
Owner

Are you that we have to use a timer. When the app comes back from background I think this gets called automatically?

@kristfal
Copy link
Author

I think the timer is a safeguard. I don’t fully understand the lifecycle of RN and Android, so I don’t have a solid answer.

@simonhoss
Copy link
Owner

@kristfal I made a new version can you please check it?

@kristfal
Copy link
Author

Thanks! I’ll include it next weeks release.

@jeremyscatigna
Copy link

Hi, I'm running the same error TouchThroughTouchHandlerInterface was not set on app activity, I've installed the lib like this in my package.json ("react-native-touch-through-view": "github:simonhoss/react-native-touch-through-view") is it good ?

@simonhoss
Copy link
Owner

Hi @jeremyscatigna you can use directly the npm package https://www.npmjs.com/package/react-native-touch-through-view

Because of the error, did you follow the android installation instruction as described here: https://github.com/simonhoss/react-native-touch-through-view#android-installation

@kristfal
Copy link
Author

kristfal commented Jan 25, 2019

@simonhoss I can confirm that the fix does indeed prevent the crash, but what happens now is that it doesn't initialize properly in the cases where it would crash.

As a result, touches doesn't get passed from the TouchThroughView down to the component underneath.

I do believe we need a timer/retry strategy for attaching to the activity to solve this properly.

A workaround on our end will be to wait for the app to enter foreground before we initialize the TouchThroughView and Wrapper.

@simonhoss
Copy link
Owner

@kristfal Thank you for the feedback. Is it also not possible to touch trough when you leave the view and enter it again? When my thoughts are right it should then work. If this is correct I have to figure out how we can register again when the app comes back from the background.

@kristfal
Copy link
Author

Hey again @simonhoss, we use the touch through view in our “main” view which is never unloaded from the app, so no way to test just that.

I’ll have a task to review this in our current sprint. Will likely fix this with a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants