Our app runs in immersive mode. We have an Android WebView that we want to display as a 3D plane.
For this, we create a "hidden" Android WebView that renders a user interface (html/javascript). The content of that WebView is continuously transferred into a texture we render on a 3D plane. Rendering works as expected.
For input, we receive Controller pose and button states from Magic Leap and pass touch input to our WebView with dispatchTouchEvent(event) call. This works for the most part.
However, the problem appears when the WebView continues to receive what seem to be spurious or phantom touch inputs coming directly from ML controller to the WebView. These events always have same 2D coordinates and we can't seem to find a way to block them. We tried blocking them by overriding setOnTouchListener of our Webview.
The WebView that we create within our Activity continues to receive touch input which is directly received from the controller when pressing the trigger button. We can see the system debug output from ml_input.h in Logcat.
I have attached a sample project that creates a WebView and tries to block these touch inputs. Without success. You can still click on links using the controller. That sample project is working on an Android phone, blocking touch input.
It looks like the Magic Leap Controller bypasses the Activity and sends the touch inputs directly to the WebView.
Is that controller/touch-input behaviour intentional, or is it a bug. Maybe we are missing something?
Hi @rp1, I spoke to our engineers and they recommended using onGenericMotionEvent() instead of onTouchEvent() to avoid receiving a touch event while pressing the controller trigger.
The issue may be when pressing the trigger, a scroll event can be sent continuously, which might not be avoided by onTouchEvent.
Hi @kdowney,
I have tried to block GenericMotionEvents for this WebView, but without success.
The strange thing is that the x and y coordinates for these unwanted touch events always stay the same over the lifetime of the app. It's the last position where I pointed the controller before initializing the web view.
Another thing is when pause and resume our app, the web view does not receive these spurious touch events anymore, and everything works as expected.