Viro: onClick hit test area is shifted in an AR scene half the time, half the time it's fine

Created on 20 Aug 2020  路  6Comments  路  Source: viromedia/viro

Environment

Please provide the following information about your environment:

  1. Development OS: Mac, Windows, Linux
    Mac
  2. Device OS & Version: What Android OS version (7.0, 8.0, etc.) or iOS version (11.0, 11.2) is your device running on?
    iOS 13.6
  3. Version: ViroReact version and React Native version
    rn: 0.63.2, viro-react: 2.17
  1. Device(s): What device(s) are you are seeing the issue on (i.e. iPhone X, Samsung Note 8, etc)
    iPhone 7, Android moto x, iPhone 11

Description

The onClick event sometimes doesn't fire on an ImageMarker or any content contained in an image marker. But, clicking below the image marker and it's content or most often, down and right fires the event. I've tried any number of nesting objects and moving the click handler around, but can't get onclicks to work all of the time. It seems to always work if I switch the event to hovering or dragging.

My image markers are remote image URLs. Not sure if that is part of the issue. I prefetch them in react, but not sure if that caching carries over.

Most helpful comment

Hey @teabow yeah, I figured out that it was a bug in the Viro/virocore package. I made a fix, but didn't put up a pr because I think my fix only works if you're using the entire screen for the AR and not a part of it. You can see the relevant changes in the VROViewAR.mm file here.
https://github.com/Vednus/virocore/compare/master...sl/fix/ios-tap-fix

But, you'll need to setup the viro repo and virocore repo in the same directory and go through the build steps for virocore that are outlined in their README to get it to work.

All 6 comments

I feel like it may have to do with PixelRatio not initializing correctly because of a race condition or something. I tried using performARHitTestWithPoint but there's no way to tell if the hit test touched an image marker unless I'm missing something.

Hi @Vednus, did you manage to find any workaround ? I'm encountering the same strange behavior.

Hey @teabow yeah, I figured out that it was a bug in the Viro/virocore package. I made a fix, but didn't put up a pr because I think my fix only works if you're using the entire screen for the AR and not a part of it. You can see the relevant changes in the VROViewAR.mm file here.
https://github.com/Vednus/virocore/compare/master...sl/fix/ios-tap-fix

But, you'll need to setup the viro repo and virocore repo in the same directory and go through the build steps for virocore that are outlined in their README to get it to work.

Thanks a lot @Vednus i'll try that !

Did your full screen AR scene was part of a navigation stack ? I'm using react-navigation and I'm wondering if I will have to change the way of navigating to the scene.

@teabow mine is visually in a react-navigation stack, but because of all the workarounds I was trying and some other funky stuff, it is a component in a tab bar. But, I load a black page in the navigation stack and then show the ARView, so the user thinks it's embedded in the stack.

Hey @teabow yeah, I figured out that it was a bug in the Viro/virocore package. I made a fix, but didn't put up a pr because I think my fix only works if you're using the entire screen for the AR and not a part of it. You can see the relevant changes in the VROViewAR.mm file here.
Vednus/[email protected]/fix/ios-tap-fix

But, you'll need to setup the viro repo and virocore repo in the same directory and go through the build steps for virocore that are outlined in their README to get it to work.

Thanks, it work for me.
I rebuild this and upload in https://github.com/developBeetSoftD1/react-viro. Hope to be of help to someone here

Was this page helpful?
0 / 5 - 0 ratings

Related issues

starantino picture starantino  路  6Comments

Thomas101 picture Thomas101  路  3Comments

Thomas101 picture Thomas101  路  3Comments

krishanjangir picture krishanjangir  路  4Comments

parideis picture parideis  路  4Comments