viromedia / viro

ViroReact: AR and VR using React Native
MIT License
2.31k stars 483 forks source link

isARSupportedOnDevice calls supportedCallback with unsupported ARCore device (Oneplus 3) #492

Open zoop500 opened 5 years ago

zoop500 commented 5 years ago

Environment

Please provide the following information about your environment:

  1. Development OS: Linux (Kubuntu)
  2. Device OS & Version: Android 8.0
  3. Version: react-viro 2.12.0, react-native 0.57.1
  4. Device(s): Oneplus 3

Description

Greetings, I'm facing an issue with isARSupportedOnDevice [1], which sees my Oneplus 3 device supported by ARCore. When checking the Google's list of supported devices [2], it can be seen that while Oneplus 3T is supported, Oneplus 3 is not. It should be also noted, that other development device Nexus 6P, works same way ( as expected).

As I currently do not have any other devices without AR Core support, I cannot verify if this problem only exists for this model. Our application is developed with AR as an optional feature (Android and iOS), so this is quite critical requirement for us.

If nothing else helps, my next step is to try react-native-device-info, which was suggested VikAdvani, in the issue 171 [4]. Maybe it might be suitable workaround.

If I'm using the isARSupportedOnDevice wrong way or anyone has ideas, please comment.

Reproducible Demo

  1. When when the AR Screen (react navigation) is opened, the view turns black and alert with message: "This application requires the latest version of ARCore (continue button)".

  2. This opens Google Play application with ARCore and info which states "Your device isn't compatible with this version.".

  3. Before and After the closing Google Play, handleARSupported method keeps being called forever, as presented from log snippet below (react-native log-android)

    ...
    12-21 11:04:32.101  2821  2867 I ReactNativeJS: AR is supported
    12-21 11:04:32.103  2821  2867 I ReactNativeJS: AR is supported
    ...

The following code snippet was used only for testing the support detection by using timer, which was used in the issue 428 [3], unlike in kesha-antonov's case double check does not work in my project.

  checkIsARSupported(){
    this.isARSupportedOnDevice(this.handleARNotSupported, this.handleARSupported);

    setTimeout(() => {
      this.checkIsARSupported()
    }, 5000)
  }
  componentWillMount() {
      this.checkIsARSupported()
  }
  handleARSupported() {
    console.log("AR is supported");
  }

  handleARNotSupported(reason) {
    console.log("AR not supported, with reason: " + reason);
  }

Links

[1] https://docs.viromedia.com/docs/isarsupportedondevice [2] https://developers.google.com/ar/discover/supported-devices [3] https://github.com/viromedia/viro/issues/428 [4] https://github.com/viromedia/viro/issues/171

VikAdvani commented 5 years ago

Hi @zoop500, Thanks for reporting this. Here is our internal java logic for determining whether AR is supported....

 public static ARCoreAvailability isARSupportedOnDevice(Context context) {
        ArCoreApk.Availability availability = ArCoreApk.getInstance().checkAvailability(context);
        Log.i(TAG, "ARCore availability check returned [" + availability + "]");
        if (availability.isTransient()) {
            return ARCoreAvailability.TRANSIENT;
        }
        if (availability.isSupported()) {
            return ARCoreAvailability.SUPPORTED;
        }
        if (availability.isUnknown()) {
            return ARCoreAvailability.UNKNOWN;
        }

        // If availability.isUnsupported()
        return ARCoreAvailability.UNSUPPORTED;
    }

Can you search for the log "ARCore availability check returned" and see what it prints out? If it prints supported then this points to ARCore itself reporting the incorrect value.

zoop500 commented 5 years ago

Hi @VikAdvani, Sorry for late response, I was not able to test this out until today. I followed your instructions and It seems that the issue is caused by the ARCore.

01-07 10:07:03.327 10026 11176 I Viro: ARCore availability check returned [SUPPORTED_NOT_INSTALLED]
01-07 10:07:03.328 10026 11175 I ReactNativeJS: AR is supported

While this issue is caused by the ARCore, do you know any possible workarounds for checking if the ViroARScene is working correctly? Currently the AR view of the application is completely black after returning from the Google Play Store.

VikAdvani commented 5 years ago

Hi @zoop500, Have you tried the react-native-device-info module you mentioned above? That's the only way I can think of to definitely ensure that ARCore doesn't flag a device that is not supported as supported.

zoop500 commented 5 years ago

Hi @VikAdvani, In the first post I did mention the react-native-device-info module, but It seems that I was mistaken by the way how it could be used. This was discussed in the following issue: https://github.com/viromedia/viro/issues/171#issuecomment-369713498 and the solution would be using white listing? However keeping such of list up-to-date is not possible for us in the current situation.

Testing with other device I tested our app with co-workers phone Oneplus 1, (LineageOS 14.1 ) and it has the same issue as Oneplus 3, however in this case the the app crashed without showing the Play store related alert. (step 2, Reproducible Demo)

Suggestion for the future: isARSupportedOnDevice would be more usefull, if it always returned the original result (ArCoreApk.Availability) in some form, instead of just invoking a function like handleARSupported.

zoop500 commented 5 years ago

New device tested: Motorola XT1580 Exactly same issue what I had with Oneplus3 (original post), happens with Motorola XT1580 - Moto X Force (Android 7.0). I'm starting to wonder, if the check works for any devices?

VikAdvani commented 5 years ago

Hi @zoop500, I just checked again with a Samsung s6 that is NOT supported by ARCore and got the following value: ARCore availability check returned [UNSUPPORTED_DEVICE_NOT_CAPABLE]

We'll try to get one of the phones you mentioned and test on that. However, since we rely on Google ARCore for this, we'll have to open a bug on them if their check is returning an incorrect value.

zoop500 commented 5 years ago

Hi @VikAdvani and thank you for the help with this issue, I hope that Google manages to fix this in the future. However as we do not have time to wait, I'm currently developing following workaround for solving the issue on our end.

This approach uses the react-native-installed-packages package[1], for checking if the com.google.ar.core has been installed. I have not implemented the functionality for opening Google Play store yet, but I'm currently working on it.

Simplified example

// Get array containing installed apps
var installedApps = require('react-native-installed-packages');
appArray =  installedApps.getApps();

// Check app_array for ar core package
var arPackage = appArray.find(function(_package) {
    return _package == "com.google.ar.core";
});

if(typeof arPackage === "undefined"){
 // Do required things for opening playstore
}

Links

[1] https://www.npmjs.com/package/react-native-installed-packages

ambojialur commented 2 years ago

Hi @VikAdvani and thank you for the help with this issue, I hope that Google manages to fix this in the future. However as we do not have time to wait, I'm currently developing following workaround for solving the issue on our end.

This approach uses the react-native-installed-packages package[1], for checking if the com.google.ar.core has been installed. I have not implemented the functionality for opening Google Play store yet, but I'm currently working on it.

Simplified example

// Get array containing installed apps
var installedApps = require('react-native-installed-packages');
appArray =  installedApps.getApps();

// Check app_array for ar core package
var arPackage = appArray.find(function(_package) {
  return _package == "com.google.ar.core";
});

if(typeof arPackage === "undefined"){
 // Do required things for opening playstore
}

Links

[1] https://www.npmjs.com/package/react-native-installed-packages

This solution is working for me thank you!