baldurk / renderdoc

RenderDoc is a stand-alone graphics debugging tool.

Home Page:https://renderdoc.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Android] "Error connecting to debugger" on OPPO A74

Fledered opened this issue · comments

Description

Every time I use RenderDoc to analyze applications on my Android phone, I get this pop-up.

2024-03-04 15_32_11-RenderDoc Unstable Release Build (v1 32 - 68929a567b80972e71b05a3750762941aecfa0

After reading this thread, I've tried using the nightly build v1.x branch @ 68929a56, 2024-03-03 to analyze this APK: https://renderdoc.org/jake-kart-vk.apk
But I still got the same error message.

Steps to reproduce

  1. Connect the phone via USB to the computer (with USB Debugging in developer mode on the Android device
    and USB Configuration to Media Transfer Protocol)
  2. Connect the phone to RenderDoc. The RenderDoc app launches on the phone.
    2024-03-04 15_23_37-OPPO A74
  3. Click once again on the same option to complete the connection with RenderDoc.
    2024-03-04 15_24_17-OPPO A74
  4. Click on the [...] button to select the app to launch. RenderDoc freezes before showing the pop-up.
    The connection between the phone and RenderDoc is lost.
    2024-03-04 15_25_19-RenderDoc Unstable Release Build (v1 32 - 68929a567b80972e71b05a3750762941aecfa0
  5. Select the app to test.
    2024-03-04 15_26_38-NOTES txt - Bloc-notes
  6. Click once again on this option to reconnect the phone with RenderDoc
    2024-03-04 15_27_08-OPPO A74
  7. Click on the "Launch" button
  8. On the phone, the app launch, a "Waiting for debugger" pop-up briefly appears, and the game starts with a fully pink screen (The same tint as the "missing material" pink in Unity). This pink screen only happens when the app is launched through RenderDoc. The game launches normally when it's launched from the phone directly. The game's audio work in both cases.
  9. On RenderDoc, the "Error connecting to debugger" pop-up appears.

The same thing happened on the v1.30 version of RenderDoc.
I've tried to repeat the entire process after closing the "adb.exe" program running in the background, with the same result.

Environment

  • RenderDoc version: v1.x branch @ 68929a5, 2024-03-03
  • Operating System: Windows 10
  • Graphics API: Vulkan/GLES Android 13
  • Smartphone: OPPO A74 (Android: Version 13 Security update: November 5, 2023)

The issue has now been reported on Oppo, OnePlus, and Xiaomi devices.... But with my Oppo find x6, capture and replay work fine! I have tried v1.3 and nightly on Windows and Linux, and I have tried to mess with developer setting and installation args in case something else is breaking, but no luck so far.

One difference to note: the issue was reported on Android 13 and 14 (November 5 security patch), while I have tested on Android 13 (October 5 security update) and Android 14 (Jan 5 security update), with the same results on both.

@Fledered In any case, if you are able to provide Android logs for this error it would be helpful.

@tjr-arm Here is a .txt file containing the logs that showed up when retrying the process. I'm kind of a newbie when it comes to using Android Logcat so this is a completely unfiltered list.
Logcat Logs.txt

I've also noticed that when asked to grant access to files, there were two separate RenderDocCmd apps (I've allowed access to both of them) which seems odd. Unfortunately, that's all the information I can give you right now.

I'll be able to test on a different phone later this week so I'll update this thread with the results.

Thank you for the update. The two RenderDoc apps correspond to 32 and 64 bit flavors. I will continue to investigate in the meantime.

There seem to be a few things going on here, so I will go through some key points.
The bit we are interested in starts here:

ActivityManager: Start proc 13170:com.DefaultCompany.TestKartGameVk/u0a236 for next-top-activity {com.DefaultCompany.TestKartGameVk/com.unity3d.player.UnityPlayerActivity}

Funnily enough JDW seems to be attached:

adbd    : jdwp connection from 13170

and:

13170 13170 W ActivityThread: Application com.DefaultCompany.TestKartGameVk is waiting for the debugger on port 8100... 
13170 13170 I System.out: waiting for debugger to settle...
[3 seconds later]
13170 13170 I System.out: debugger has settled (1411) 

So it does not look like an ADB issue, although it takes a while for the debugger to attach.

Then we see 'application not responding' (ANR) message, indicating that the kart app froze for a few seconds, possibly just waiting for the debugger:

ANR_LOG : >>> msg's executing time is too long  
ANR_LOG : Blocked msg = { when=-3s104ms what=110 target=android.app.ActivityThread$H obj=AppBindData{appInfo=ApplicationInfo{d0e1e10 com.DefaultCompany.TestKartGameVk}} } , cost  = 3088 ms
ANR_LOG : >>>Current msg List is:  
ANR_LOG : Current msg <1> = { when=-3s89ms what=159 target=android.app.ActivityThread$H obj=android.app.servertransaction.ClientTransaction@9c5d75fe } 
ANR_LOG : Current msg <2> = { when=-3s88ms what=159 target=android.app.ActivityThread$H obj=android.app.servertransaction.ClientTransaction@ba0eb2ef }
ANR_LOG : Current msg <3> = { when=-2s787ms what=149 target=android.app.ActivityThread$H obj=android.os.BinderProxy@99f0b3c } 
ANR_LOG : Current msg <4> = { when=-14ms what=164 target=android.app.ActivityThread$H obj=com.DefaultCompany.TestKartGameVk }
ANR_LOG : >>>CURRENT MSG DUMP OVER<<<  

in conjunction with SELinux AVC policy violation:

.TestKartGameVk: ofbOpen failed with error=No such file or directory 
.TestKartGameVk: sysOpen failed with error=No such file or directory
.TestKartGameVk: type=1400 audit(0.0:161726): avc: denied { search } for n
.TestKartGameVk: type=1400 audit(0.0:161726): avc: denied { search } for name="sched_assist" dev="proc" ino=4026532185 scontext=u:r:untrusted_app:s0:c236,c256,c512,c768 tcontext=u:object_r:oplus_scheduler_sched_assist_proc:s0 tclass=dir permissive=0 app=com.DefaultCompany.TestKartGameVk 

And a little later, we cannot load assets, hence pink screen:

I Quality : LaunchTime2.0: com.DefaultCompany.TestKartGameVk/com.unity3d.player.UnityPlayerActivity 1 4488 NULL, OPEN FILE ERROR... 
I DispPerfService: updateLayerMask 0
D VRI[UnityPlayerActivity]: onFocusEvent true
E SurfaceSyncer: Failed to find sync for id=0
D VRI[UnityPlayerActivity]: draw finished. 

It almost looks like two separate issues to me.
The time delay between waiting for the debugger on port 8100... and debugger has settled (1411) is 3 seconds, but in code, a shorter fixed delay is used:

    Android::adbForwardPorts(m_portbase, m_deviceID, jdwpPort, pid, false);

    // sleep a little to let the ports initialise
    Threading::Sleep(50);

    if(jdwpPort)
    ...

Just from the logs, its entirely possible that increasing the delay or polling the port will allow the debugger time to connect. That does not address the pink screen effect you describe, which could be explained by an overzealous security policy on this device and version. We have previously seen instances where these devices silently do not grant requested permissions on install, so it is possible that manually reinstalling both the RenderDoc remote server APK and test APK with -g would bypass these policies.

adb install -r -g --force-queryable ./share/renderdoc/plugins/android/org.renderdoc.renderdoccmd.arm32.apk 
adb install -r -g --force-queryable ./share/renderdoc/plugins/android/org.renderdoc.renderdoccmd.arm64.apk

Then ensuring they both have all access (Apps->App management->RenderDocCmd->Permissions)

Without to means to reproduce locally, it will be difficult to confirm what is actually happening and how best to address it.

So !

I've tried increasing the "debugger delay" and manually reinstalling the RenderDoc remote servers with -g, but none of these worked. I don't know what "polling the port" means or how to do it and I couldn't find a google search to help me :(
2024-03-08 18_21_20-zz rdc - RenderDoc Unstable Release Build (v1 32 - 68929a567b80972e71b05a3750762

However, I tried using a different phone :

  • RenderDoc version: v1.x branch @ 68929a5, 2024-03-03
  • Operating System: Windows 10
  • Graphics API: GLES Android 7
  • Smartphone: Sony Xperia Z5 Compact (E5823) (Android 7.1.2)

And it worked perfectly, both with the kart game and a build of my own game project. The kart game was still pink but I could capture it. The time delay between 'waiting for the debugger on port 8100...' and 'debugger has settled (1411)' is also 3 seconds but it still worked without any debugger delay.

So this is definitely a problem with the phone itself.

Here are the logcat logs on the same kart game apk I get on this new phone :
New Phone LogcatLogs.txt

I don't know if that can be useful but that's sadly all the info I can give.

Thank you for the update. What you describe supports the theory that pink screen is a separate APK issue.

To clarify, the fix I suggested would require a change to source code and local build to test, but since I can't reproduce on my end it is a pure guess and far from ideal. For that reason we can probably close this issue off (device specific + cannot reproduce).

I just solved the issue posted here for Xiaomi device. I was getting the exact same errors and here is the fix:

SETTING UP THE PHONE
On phone, go to Settings -> Additional Settings -> Developer Options -> Enable USB debugging. You need a SIM card and internet connection for this.

On phone, go to Settings -> Additional Settings -> Developer Options -> Enable USB debugging (security settings) SIM card and internet connection is required for this also.

UNINSTALL RENDERDOC ON PHONE IF NECESSARY
On phone, go to Settings -> Apps -> Manage Apps -> RenderDocCmd -> Uninstall (do this for both RenderDocCmd apps)

INSTALL RENDERDOC FOR PC IF NECESSARY
Download and install RenderDoc for PC from here: https://renderdoc.org/builds

TEST ADB CONNECTION IF NECESSARY
Ensure the phone is connected via USB. You have to trust device when promted.
On the PC, open a command window (Start -> cmd). Change directory to where you saved ADB using command cd C:\Users<YourName>\AppData\Local\Android\Sdk\platform-tools (you will need to change the path to where adb is saved on your machine).
Enter command adb devices
I typed adb devices and got “cf63ad22 unauthorized” because I hadn’t yet trusted the PC on the phone. Once I did that, I got “cf63ad22 device” which confirmed successful connection.

INSTALL RENDERDOC TO PHONE USING ADB ON PC
Locate the folder on your PC where org.renderdoc.renderdoccmd.arm32.apk and org.renderdoc.renderdoccmd.arm64.apk are stored. For example, C:\Program Files\RenderDoc\plugins\android. Copy this file path.
Locate the folder where you have adb installed. For example, C:\Users<YourName>\AppData\Local\Android\Sdk\platform-tools.
Run command line from this folder (launch cmd and use command cd C:\Users<YourName>\AppData\Local\Android\Sdk\platform-tools).
Enter adb install command and paste the file path you copied:
adb install -r -g --force-queryable "C:\Program Files\RenderDoc\plugins\android\org.renderdoc.renderdoccmd.arm32.apk"
and:
adb install -r -g --force-queryable "C:\Program Files\RenderDoc\plugins\android\org.renderdoc.renderdoccmd.arm64.apk"

SET PERMISSIONS ON PHONE
On phone, go to Settings -> Additional Settings -> Developer Options -> Select Debug App and choose the topmost RenderDocCmd app

On phone, go to Settings -> Apps -> Manage Apps -> RenderDocCmd then go to App permissions and give permissions for Files, Music, etc. Do this for both RenderDocCmd apps.

Please do not comment on old issues that have been closed.

If you are encountering a bug or are requesting a feature please open a new issue. You can reference this issue if you wish, but opening a new issue prevents any confusion of accidentally linking two unrelated issues and means that each issue can be handled in a clean process.