Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access camera on Android 10+ #710

Open
chernyadev opened this issue Jul 19, 2021 · 17 comments
Open

Access camera on Android 10+ #710

chernyadev opened this issue Jul 19, 2021 · 17 comments

Comments

@chernyadev
Copy link

Hello!

I've faced an issue accessing file uploading dialogue on Android 10+ devices (works perfectly for lover versions). I only can attach files from the gallery but am not able to take new pictures. It seems to be related to issues described on Stackoverflow:

Please let me know if that problem could be resolved with any kind of manifest magic or I'm doing something wrong. Thank you in advance!

Best regards!

@KojiNakamaru
Copy link
Member

I fixed the code and updated binaries. Could you please try the latest.

@eb0KrY4k
Copy link

I fixed the code and updated binaries. Could you please try the latest.

In android 11, this problem is observed on some devices.

@KojiNakamaru
Copy link
Member

Settings for allowing camera access with file input field are a bit complicated.

https://github.com/gree/unity-webview/tree/acc3c327128d5ffb71d619fb79d08dc16199f03b#file-input-field
https://github.com/gree/unity-webview/tree/acc3c327128d5ffb71d619fb79d08dc16199f03b#cameraaudio-permissionfeature

In short, you should

  • set Player Settings/Other Settings/Write Permission to External (SDCard)
  • define UNITYWEBVIEW_ANDROID_ENABLE_CAMERA
  • invoke webViewObject.SetCameraAccess(true);

Could you please check these settings?

@eb0KrY4k
Copy link

eb0KrY4k commented Oct 23, 2021

Settings for allowing camera access with file input field are a bit complicated.

https://github.com/gree/unity-webview/tree/acc3c327128d5ffb71d619fb79d08dc16199f03b#file-input-field https://github.com/gree/unity-webview/tree/acc3c327128d5ffb71d619fb79d08dc16199f03b#cameraaudio-permissionfeature

In short, you should

  • set Player Settings/Other Settings/Write Permission to External (SDCard)
  • define UNITYWEBVIEW_ANDROID_ENABLE_CAMERA
  • invoke webViewObject.SetCameraAccess(true);

Could you please check these settings?

Could you tell me at what point it is better to do this? before launching the application or at the time of creating a webview? it turns out that on xiaomi (11 android) and samsung (11 android) the camera works correctly, but on realme and zte it does not work

@KojiNakamaru
Copy link
Member

KojiNakamaru commented Oct 24, 2021

How far does the app go? Can you see a popup like the following when you tap a file input button?

image

@eb0KrY4k
Copy link

How far does the app go? Can you see a popup like the following when you tap a file input button?

image

I see this window, I can open the camera, take a photo, but when I click the confirmation icon, "Camera error, unable to save photo or video" appears

@KojiNakamaru
Copy link
Member

Thank you for the report. I investigated further and introduced a fix for Android 7 or later in #743 . Could you please try the latest?

@eb0KrY4k
Copy link

eb0KrY4k commented Oct 25, 2021

Android 10 camera won't launch, on Android 11 devices where the camera didn't launch now crashes. But if you first open "Files" and then "Camera", then everything works fine on Android 11. I experimented: if I add uses-permission android: name = "android.permission.MANAGE_EXTERNAL_STORAGE" in the manifest and give permissions to all files, it works on android 11, but if I cancel the photo, then the next time I open the camera, the app crashes.

@KojiNakamaru
Copy link
Member

Could you please upload the sample app project that reproduce the issue? I would like to check various settings, the unity version, etc. to reproduce issues. Could you please also upload adb logcat output when any crash happened? It would be a clue to figure out the cause.

@eb0KrY4k
Copy link

@KojiNakamaru
Copy link
Member

Thank you for those files. Though I couldn't reproduce the issue on my OSCAL Pad 8 (Android 11, https://www.devicespecifications.com/en/model/8edb570f ), I found a similar behavior on emulator. I adjusted the logic and the build process in #745 and #744 so could you please try the latest? Please note the latest binaries don't contain Assets/Plugins/Android/core-1.6.0.aar (instead it contains Assets/Plugins/Android/core-1.6.0.aar.tmpl) so you need to remove Assets/Plugins/Android/core-1.6.0.aar.

BTW, the log you sent seems to show some native code crash. This might happen because of graphics driver's instability. If OpenGLES3 is sufficient for your project, limiting the graphics api to OpenGLES3 could also help bring stability.

@eb0KrY4k
Copy link

Thanks, everything works fine now

@eb0KrY4k
Copy link

After recent updates, the camera stopped working again

Thank you for those files. Though I couldn't reproduce the issue on my OSCAL Pad 8 (Android 11, https://www.devicespecifications.com/en/model/8edb570f ), I found a similar behavior on emulator. I adjusted the logic and the build process in #745 and #744 so could you please try the latest? Please note the latest binaries don't contain Assets/Plugins/Android/core-1.6.0.aar (instead it contains Assets/Plugins/Android/core-1.6.0.aar.tmpl) so you need to remove Assets/Plugins/Android/core-1.6.0.aar.

BTW, the log you sent seems to show some native code crash. This might happen because of graphics driver's instability. If OpenGLES3 is sufficient for your project, limiting the graphics api to OpenGLES3 could also help bring stability.
After recent updates, the camera stopped working again

@KojiNakamaru
Copy link
Member

How doesn't it work? Changes since the last time are the followings:

81d56f3...ffbf3c1

and they don't contain any change directly related to camera. The sample app and its binary that runs on my devices can be found in the following, so could you please try it.

#751 (comment)
(https://github.com/gree/unity-webview/tree/992d2006ae1503f1df44a1fef69d774fcd95acf0/sample is for 2020.3.22f1, which can be easily upgraded to 2021.x).

@eb0KrY4k
Copy link

Hello. All the same, camera crashes are observed, the latest version of the plug-in and your Sample are used. If the crash didn't work the first time, you can reset the app and try again. Apk and logs: https://drive.google.com/file/d/1KDOL5sFedvnGuR3FX9FXrku17DWGa9dl/view?usp=sharing

@eb0KrY4k
Copy link

Do I have a plugin with android native functionality? in it, the camera works fine, if I can throw it off for comparison.

@KojiNakamaru
Copy link
Member

Your app worked okay on my devices.

  • For Vankyo S7 (Android 9), the camera worked okay for the first and for the second launch with clearing data.
  • For OSCAL Pad 8 (Android 11), the camera worked okay for the first launch.

I couldn't test further as a sort of reCAPTCHA was displayed and I couldn't input Cyrillic glyphs.

Your log contains some vulkan-related messages so I guess you enabled vulkan for your app. As vulkan is rather unstable on some devices, disabling it could help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants