androidmauivisual-studio-debugging.net-8.0

MAUI USB Android debug fails after changes in code


After I change some code and running the app in USB debug in physical Android phone, the debugging stops at seconds after launching the app, at the same time the app goes to background and gets "cleared". When I bring the app back to the front, it restarts and works correctly in the phone, however it's already disconnected from Visual Studio anyways. To stop the failing from happening I have to uninstall the app from the device, but if I change code again, it starts failing again.

There's no exception reported, nor backtrace, and there is very little output when this happens.

Here are the last output lines on this failure:

[OpenGLRenderer] Davey! duration=1053ms; Flags=0, FrameTimelineVsyncId=750240, IntendedVsync=11939588219664, Vsync=11940621552956, InputEventId=0, HandleInputStart=11940627184818, AnimationStart=11940627189245, PerformTraversalsStart=11940627835078, DrawStart=11940628308047, FrameDeadline=11940638251820, FrameInterval=11940626035339, FrameStartTime=16666666, SyncQueued=11940630990078, SyncStart=11940631119089, IssueDrawCommandsStart=11940631489245, SwapBuffers=11940636915703, FrameCompleted=11940642056224, DequeueBufferDuration=36198, QueueBufferDuration=440990, GpuCompleted=11940642056224, SwapBuffersCompleted=11940638637161, DisplayPresentTime=0, CommandSubmissionCompleted=11940636915703,
Thread started: .NET Timer #8
[Quality] Skipped: false 3 cost 53.28309 refreshRate 16669135 bit true processName com.mycompany.myapp
[VRI[MainActivity]] Received frameCommittedCallback lastAttemptedDrawFrameNum=3 didProduceBuffer=true syncBuffer=false
[VRI[MainActivity]] draw finished.
[VRI[MainActivity]] reportDrawFinished
[Quality] Skipped: false 6 cost 110.21765 refreshRate 16667980 bit true processName com.mycompany.myapp
[Quality] Skipped: false 1 cost 18.913912 refreshRate 16667282 bit true processName com.mycompany.myapp
[OplusScrollToTopManager] com.mycompany.myapp/crc6476ca92efe8ec1437.MainActivity,This DecorView@88d844b[MainActivity] change focus to true
[mycompany.myapp] Explicit concurrent copying GC freed 13427(558KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 6259KB/12MB, paused 26us,14us total 12.446ms
[monodroid-assembly] open_from_bundles: failed to load assembly System.Xml.XmlSerializer.dll
Loaded assembly: /data/data/com.mycompany.myapp/files/.__override__/System.Xml.XmlSerializer.dll [External]
Thread started: <Thread Pool> #9
Thread started: <Thread Pool> #10
Thread started: <Thread Pool> #11
Thread started: <Thread Pool> #12
Thread started: <Thread Pool> #13
Thread started: <Thread Pool> #14
Thread started: <Thread Pool> #15
[ProfileInstaller] Installing profile for com.mycompany.myapp

*** At this point everything looks normal, the app is running and usable,
but then it gets "cleared" and the only output I get are the following lines: ***

[libc] Requested dump for pid 31373 (mycompany.myapp)
[Looper] dumpMergedQueue
[OplusLooperMsgDispatcher] dumpMsgWhenAnr

Things I have already tried without any success:

I am using .NET 8.0


Solution

  • Part of logcat file :

    [libc] Requested dump for pid 31373 (mycompany.myapp)
    [Looper] dumpMergedQueue
    [OplusLooperMsgDispatcher] dumpMsgWhenAnr
    

    dumpMsgWhenAnr states to dump you app once it crashes with ANR (Application not responding error) as your app might be performing heavy operations on the main thread or using too much resources of device. There are exploits that move long-running operations off the main thread, another focuses on rendering and memory optimizations, the last several address several thread management issues. There are many profiling tools and ways that you can use in Android Studio to find specific problems and optimise your application and its performance in the right manner.

    ANR is a state that occurs when a main thread of the application that has been locked for a duration greater than five seconds or if the application is busy for more than 10 secs while using a BroadcastReceiver. It receives and handles broadcast intents.


    Diagnosing the Problem :

    1. Long-running Operations on Main Thread

    2. Heavy Rendering or UI Operations

    3. Inefficient Memory Usage

    4. Thread Management

    Check from the output of the program that your background threads are not harming the system.

    Here are details of the threads started:

    Loaded assembly: /data/data/com.mycompany.myapp/files/.__override__/System.Xml.XmlSerializer.dll [External]
    Thread started: <Thread Pool> #9
    Thread started: <Thread Pool> #10
    Thread started: <Thread Pool> #11
    Thread started: <Thread Pool> #12
    Thread started: <Thread Pool> #13
    Thread started: <Thread Pool> #14
    Thread started: <Thread Pool> #15
    

    Keep an eye on your background threads so as not to overburden the system. The log shows that multiple threads in the thread pool begin as evidenced by the following entry format: Be certain that you are not generating too many threads, and thus, experiencing leakage of the thread contentions and the performance.


    If you have difficulty in solving some part of your code, someone out there can assist you more if you present that section of code.

    Refrence links :