I managed to run krpano with WebVR on Chrome and Firefox, and the cardboard button is visible and enabled. But upon running it embeded inside a WebView in Android, it doesn't show the cardboard button.
But then, I found out that my compiled apk with the WebView is showing the cardboard button on my other device. How will I force the same behavior on my phone, because I know it works in Chrome and Firefox Mobile on my android phone but not when using my WebView implementation?
What configuration do I have to set? Or simulate in order to ensure WebVR is enabled to all android devices that can support it and not just to some devices or in the device's discretion, even if it can really run it?
static final String BASE = "http://app.imaginarydomain.com";
static final Pattern PATH_PATTERN = Pattern.compile(Pattern.quote(BASE) + "/(.*)");
...
WebSettings webSettings = webView.getSettings();
webSettings.setBlockNetworkLoads(false);
webSettings.setJavaScriptEnabled(true);
webView.setWebViewClient(new TestWebViewClient());
webView.loadUrl(BASE + "/tour.html");
...
class TestWebViewClient extends WebViewClient {
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
Matcher matcher = PATH_PATTERN.matcher(url);
if (matcher.matches()) {
String asset = "sample-tour-cardboard/" + matcher.group(1);
try {
InputStream is = getAssets().open(asset);
String extension = MimeTypeMap.getFileExtensionFromUrl(url);
String type = "application/octet-stream";
if (extension != null) {
type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
}
return new WebResourceResponse(type, "UTF-8", is);
} catch (IOException e) {
Log.e("ERROR!", "Asset loading error: " + asset, e);
}
}
return null;
}
}
I also tried to enable WebVR fake mode in krpano WebView plugin. But it doesn't work.
I'm guessing that WebVR plugin is checking something in the WebView's context and that the check only succeeds on Chrome Mobile, Firefox Mobile, or on other implementations by other devices.
The WebVr plugin used by krpano needs WebGL, which comes shipped in the Android WebView only after the Android L Developer Preview.
More info on this limitation are offered on the developer page of chrome : https://developer.chrome.com/multidevice/webview/overview
For this reason the cardboard icon won't show in the Android WebView.
If you need to support prelollipop devices, you can use the XWalkView from the XWalk Project.
Link: https://crosswalk-project.org/documentation/embedding_crosswalk.html .
For some extra help, here's the link to my discussion about embedding xwalk on the krpano forum: http://krpano.com/forum/wbb/index.php?page=Thread&postID=61064