playcanvas / playcanvas-ar

Fast and Easy Augmented Reality for the Web :rocket:
MIT License
237 stars 67 forks source link

Not working on Android #7

Closed Epikos1994 closed 6 years ago

Epikos1994 commented 6 years ago

Currently having an issue getting the camera to work on Android devices. The play canvas app launches and then just shows a grey/blue screen. This is also reproducible in the demo example you provided.

I tried adding a UI to see if the app wasn't launching at all but I could see it. So it looks like an issue with init/rendering the camera from the device?

I'll test IOS when I get the chance.

I tried looking around in the source to see if I could identify the problem, but no luck. Just moved to PlayCanvas from Unity, Loving working with AR so far. Fun and easy to play around with.

Any help would be appreciated. Thanks.

willeastcott commented 6 years ago

Seems to work fine here on a Huawei Honor:

img_0178

What device(s) and browser(s) are you having problems with?

Epikos1994 commented 6 years ago

Tested with a Samsung J5 and a Samsung Note 4.

Mainly testing with the Note 4. Android v6.0.1

Playcanvas shows, loads, completes and then this screen.

screenshot_2018-02-20-12-59-35-resize

willeastcott commented 6 years ago

And you never see the dialog asking for permission to use the camera? What do you see if you go to http://get.webgl.org? Can you remote debug the problem device(s) and get the JavaScript console output?

Epikos1994 commented 6 years ago

Nope, No Dialog asking about the camera.

image

I can, however, dont have access to pc atm. I'll take a look when so.

willeastcott commented 6 years ago

Wait. There’s no lock on your browser when viewing the app. Does that mean you’re not viewing the link over https? Https is required for camera access.

Epikos1994 commented 6 years ago

Ive just checked. Still the same issue. I tried incognito also to see if there were possible cache settings or something. But the only permissions the page says it has/needed are for sound.

Also reset page settings and data. No luck.

Ill send a screenshot when I get to a pc.

cognitiveplus commented 6 years ago

I have the same issue on Xiaomi Redmi 3, Android 5.1.1. Although I get camera dialog on the first try, after confirming it the screen is grey. On subsequent tries there is no camera dialog, only grey screen.

Will try to clone this project, build my custom version and debug it.

willeastcott commented 6 years ago

OK, let me know what you find out. 😄

cognitiveplus commented 6 years ago

Ok, here are some findings:

It also may be the issue with getting input from device camera, since placing AR marker in front of it doesn't fire up the cube - so seems like the script doesn't see camera input and can't process it

Epikos1994 commented 6 years ago

Sorry haven't been active. On holiday atm. I'll be back on Thursday to help out.

Gl

cognitiveplus commented 6 years ago

Another finding - removing calibration .dat file from ArCamera script attribute seems to break desktop version in the same way as it's currently broken on my android - i.e. it just loads to dark grey and doesn't do anything. May be there is an issue with camera calibration file on some androids?

cognitiveplus commented 6 years ago

I've found the culprit: ArCamera.prototype.enterAr :: navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {...}) - the code flow doesn't reach inside this callback. No error is caught though.

cognitiveplus commented 6 years ago

EDIT: Actually, there is a error - unable to acquire camera stream. Error logging was just broken in .catch branch.

willeastcott commented 6 years ago

Hmm. Are you able to run any non-PlayCanvas apps on your device that use getUserMedia? For example:

https://webrtc.github.io/samples/src/content/getusermedia/gum/

cognitiveplus commented 6 years ago

Nope, getting NotReadableError at this link. Seems like hardware / os issue with my device.

willeastcott commented 6 years ago

Hmm. Seems so. Weird.

Epikos1994 commented 6 years ago

Hey Gents,

So I've been looking around and testing some things out. This looks like an issue for Chrome.

I tested the app using Samsung internet and I get the request to access camera and the app works fine. (However it was using my front camera)

I'll keep digging some more and let you know what I find.

willeastcott commented 6 years ago

If this is a Chrome bug (regression?), then you might want to report it on:

https://bugs.chromium.org/p/chromium/issues/list

They're normally quite responsive.

cognitiveplus commented 6 years ago

It works in Firefox for me, so seems like Chrome issue indeed.

Epikos1994 commented 6 years ago

Hey Guys,

It's now working on Chrome. Believe this is Issue fixed?

Thanks, Dean

willeastcott commented 6 years ago

Thanks for the update. Closing...