question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some Androids (E.g. HUAWEI) cannot properly wait for camera permissions

See original GitHub issue

Plugin Version or Commit ID

v0.10.3

Unity Version

2021.3.4f1

Your Host OS

win11

Target Platform

Android

Target Device

No response

[Windows Only] Visual Studio C++ and Windows SDK Version

No response

[Linux Only] GCC/G++ and GLIBC Version

No response

[Android Only] Android Build Tools and NDK Version

No response

[iOS Only] XCode Version

No response

Build Command

python build.py build --android arm64 --android_ndk_api_level 21 -vv

Bug Description

Open the apk for the first installation,it doesn’t work It works the second time you open it I think “Callback RequestUserPermission” should be used

https://docs.unity3d.com/ScriptReference/Android.Permission.RequestUserPermission.html

WebCamSource.cs

#if UNITY_ANDROID
        if (!Permission.HasUserAuthorizedPermission(Permission.Camera))
        {
+         bool permissionResponse = false;
+         var callbacks = new PermissionCallbacks();
+         callbacks.PermissionDenied += (string permissionName) => { permissionResponse = true; };
+         callbacks.PermissionGranted += (string permissionName) => { permissionResponse = true; };
+         callbacks.PermissionDeniedAndDontAskAgain += (string permissionName) => { permissionResponse = true; };

+         Permission.RequestUserPermission(Permission.Camera, callbacks);
+         yield return new WaitUntil(() => permissionResponse);
-         Permission.RequestUserPermission(Permission.Camera);
-         yield return new WaitForSeconds(0.1f);
        }
#elif UNITY_IOS

Steps to Reproduce the Bug

open apk

Log

no log

Screenshot/Video

No response

Additional Context

No response

Issue Analytics

  • State:open
  • Created 8 months ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
jsaon-Lcommented, Jan 13, 2023

https://user-images.githubusercontent.com/17309378/212228720-8e3bb10a-4e1a-4129-bde0-a3676a4b2ba2.mp4

log.txt


i add debug log in script “Start RequestUserPermission” “End RequestUserPermission” image

0reactions
jsaon-Lcommented, Apr 25, 2023

您会检查#829是否解决此问题吗?

After my testing this submission does not solve this problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android: Permission Denial: starting Intent with revoked ...
1- Go to Settings of your emulator. 2- Look for Apps and Notifications. 3- Click on Add Permission. see the pic : https://i.stack.imgur....
Read more >
How to Fix "Can't Connect to the Camera" Issue
Tap and hold the Power Off option for a couple of seconds then confirm that you want to go on Reboot to Safe...
Read more >
[camera] Huawei devices running Android 7/8 throw ...
Getting this error when taking picture with both front and rear camera on Huawei Mate 10 Lite. I was hoping that Camera 0.9.0...
Read more >
Change app permissions on your Android phone
To change a permission setting, tap it, then choose Allow or Don't allow. For location, camera, and microphone permissions, you may be able...
Read more >
Find the Normal Mode images using Huawei Camera ...
Introduction In this article, we can learn about the Normal Mode type images captured by Huawei Camera Engine. This mode supports the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found