Bug 42375 - ZTE Z716BLB01 / Android 5.1.1 Infinite hang : Trying to initialize the debugger
Summary: ZTE Z716BLB01 / Android 5.1.1 Infinite hang : Trying to initialize the debugger
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Debugger ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: master
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-07-06 03:55 UTC by RobertN
Modified: 2017-04-07 20:20 UTC (History)
8 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
AndroidTools and Ide logs for failed debug session on TCT A517 (6.81 KB, application/zip)
2017-01-10 22:00 UTC, Eric Hedstrom
Details
adb ps shell (34.29 KB, text/plain)
2017-02-02 06:17 UTC, RobertN
Details
logcat debug session (210.13 KB, text/plain)
2017-03-28 04:21 UTC, RobertN
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 42375 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description RobertN 2016-07-06 03:55:01 UTC
We have added the following device on our testing suite/environment to trace/debug end-user run-time issues but the debugger never attaches to the device (Android Studio does connect and debug properly to the same device):

   Device : ZTE Z716BLB01  / Android 5.1.1

Note: The deployed/installed (release & debug) apk does run correctly independently of the IDE when started manually

Xamarin Studio "Application output" of a non-modified template created Android app:

Forwarding debugger port 8866
Detecting existing process
> am start -n "com.sushihangover.ztetestdebugging/md5c4a2c575ff4d573ba8e8bab7833a0b82.MainActivity"
> Starting: Intent { cmp=com.sushihangover.ztetestdebugging/md5c4a2c575ff4d573ba8e8bab7833a0b82.MainActivity }

[art] Late-enabling -Xcheck:jni
[monodroid] Using override path: /data/data/com.sushihangover.ztetestdebugging/files/.__override__
[monodroid] Using override path: /storage/emulated/0/Android/data/com.sushihangover.ztetestdebugging/files/.__override__
[monodroid] Trying to load sgen from: /data/data/com.sushihangover.ztetestdebugging/files/.__override__/libmonosgen-2.0.so
[monodroid] Trying to load sgen from: /storage/emulated/0/Android/data/com.sushihangover.ztetestdebugging/files/.__override__/libmonosgen-2.0.so
[monodroid] Trying to load sgen from: /data/app/com.sushihangover.ztetestdebugging-1/lib/arm/libmonosgen-2.0.so
[monodroid] Trying to load sgen from: /data/data/com.sushihangover.ztetestdebugging/files/.__override__/links/libmonosgen-2.0.so
[monodroid-debug] Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8866,server=y,embedding=1

(Debugger never connects and the application on the device that is launched only displays a blank screen/activity)

The same device on Android Studio works property (a single-activity template created application):

07/05 20:26:05: Launching app
$ adb push /Users/sushi/code/XamTests/MyApplication2/app/build/outputs/apk/app-debug.apk /data/local/tmp/com.sushihangover.myapplication
$ adb shell pm install -r "/data/local/tmp/com.sushihangover.myapplication"
	pkg: /data/local/tmp/com.sushihangover.myapplication
Success

$ adb shell am start -D -n "com.sushihangover.myapplication/com.sushihangover.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Waiting for application to come online: com.sushihangover.myapplication.test | com.sushihangover.myapplication
Connecting to com.sushihangover.myapplication
Connected to the target VM, address: 'localhost:8600', transport: 'socket'


Environment:
OS-X 10.11.5
Xamarin.Android Version: 6.1.99.224 
Xamarin Studio Community Version 6.1 (build 4963)

SDK Tools Version: 25.1.7
SDK Platform Tools Version: 24
SDK Build Tools Version: 24

Java SDK: /usr
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
Comment 1 RobertN 2016-07-10 02:03:02 UTC
I changed the product from Xamarin.Android to Xamarin Studio to see if I can get any traction on this issue
Comment 4 RobertN 2016-08-03 20:19:06 UTC
Samsung Galaxy S5? 

This is a device specific problem causes some issue with Xamarin/Mono debugger as Android Studio deploys to and its debugger connects fine.

The client has over 1000 Android devices and now has 6(+?) devices that the Mono debugger will not connect to. But all of these devices work fine with Android Studio.
Comment 5 Greg Munn 2016-12-19 21:58:50 UTC
Sorry Robert, I didn't see your bug report earlier - when you re-assigned it you didn't have "reset assignee to default" selected and I wasn't notified.

> The same device on Android Studio works property (a single-activity template created application):

This would be that the application in question isn't trying to make a tcp connection back to Android Studio - which is what's happening when "Trying to initialize the debugger"

Did you have any luck with this since you reported the issue? If not, can we start off with attaching the ide and android logs from Help | Open Log Directory. We might be able to see what's going on from there.

Once again, apologies for not seeing this earlier.
Comment 6 Eric Hedstrom 2017-01-10 22:00:36 UTC
Created attachment 19166 [details]
AndroidTools and Ide logs for failed debug session on TCT A517
Comment 7 Eric Hedstrom 2017-01-10 22:02:09 UTC
I am having the same issue with two devices, a TCT A517VL (Alcatel Onetouch) and a ZTE Z717VL. I'm attaching logs from the TCT.

Running the app without debug works fine, but with debug the debugger is never able to attach.
Comment 8 Eric Hedstrom 2017-01-10 22:15:24 UTC
Both devices with this problem have Android 5.1.1. We also have an LG G3 with 4.4.2 that Xamarin Studio is able to debug with.
Comment 9 RobertN 2017-02-01 07:04:48 UTC
@GregMunn : No I have no been able to get these devices to work.  There currently are multiple dozens of Android model/phones that fail to connect via Xamarin (XS, VS4M) but work fine (in terms of debugging) with Android Studio.

In fact one client (I am a contractor for them), drop future Xamarin projects due to this issue as they are unable to debug on these "Chinese Generic" Android devices since they are contained within their private/in-house testing cloud (1000+ devices) and wifi-based debugging is not an option. They are an Microsoft Dev/Tech Partner and went through those channels with no solution...

I know of three other clients that have the same issue. I actually bought a ZTE Z716BLB01 ($30USD) to try to determine why Xamarin will not connect, it appears that Android Studio is setting some props via adb/shell that Xamarin is not before forwarding the debug port (but Android Studio starts debugging sessions totally different then Xamarin so not sure if that is actually the root cause/solution)

It is interesting that "Eric Hedstrom" noted both his devices failing are "5.1.1", as my ZTE Z716BLB01 is 5.1.1 and I know *some* of the other ZTE and "Chinese Generic" devices that fail are 5.1.1 also.

Currently running:

  Xamarin Studio Community Version 6.2 (build 1778)
  Visual Studio for Mac Preview Version Preview 3 (7.0 build 1077)
  Xamarin.Android Version: 7.1.0.25
Comment 10 Greg Munn 2017-02-01 16:01:31 UTC
Thanks Eric and Robert. There's one thing you can do for me to help track this down and that is to shell to the device and grab the output of the `ps` command and attach it to the report. If that doesn't give us anything to go on, we'll look at getting some of these devices to test with (we should probably do that anyway, but we have to place orders for them and I don't know the process for that as well as i used to now that we're microsoft :) )

so, can you capture the output from `adb shell ps` and attach it here please.
Comment 11 RobertN 2017-02-02 06:16:47 UTC
Deploying to device output:

    Detecting installed packages
    Removing old runtimes
    Installing shared runtime
    Installing platform framework
    Installing application on device
    Synchronizing assemblies   
    Deployment completed

Application Output:

    Forwarding debugger port 8845
    Detecting existing process
    > am start -n     "com.sushhangover.customtabsdemos/com.sushhangover.androidcustomtabs.DemoListActivity"
    > Starting: Intent { cmp=com.sushhangover.customtabsdemos/com.sushhangover.androidcustomtabs.DemoListActivity }

    User assembly     '/Users/sushi/code/sushi/SushiHangover.CustomTabs.Shared/src/Application/bin/Debug/CustomTabsClient.dll' is missing. Debugger will now debug all code, not just user code.
    [art] Late-enabling -Xcheck:jni
    [monodroid] Using override path:     /data/data/com.sushhangover.customtabsdemos/files/.__override__
[monodroid] Using override path: /storage/emulated/0/Android/data/com.sushhangover.customtabsdemos/files/.__override__
    [monodroid] Trying to load sgen from: /data/data/com.sushhangover.customtabsdemos/files/.__override__/libmonosgen-2.0.so
    [monodroid] Trying to load sgen from: /storage/emulated/0/Android/data/com.sushhangover.customtabsdemos/files/.__override__/libmonosgen-2.0.so
    [monodroid] Trying to load sgen from: /data/app/com.sushhangover.customtabsdemos-1/lib/arm/libmonosgen-2.0.so
    [monodroid] Trying to load sgen from: /data/data/com.sushhangover.customtabsdemos/files/.__override__/links/libmonosgen-2.0.so
    [monodroid-debug] Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8845,server=y,embedding=1

Attaching "adb shell ps" as "shell-ps-debug-hang.txt" that was run during the debugging session at this point: ([monodroid-debug] Trying to initialize the debugger....)
Comment 12 RobertN 2017-02-02 06:17:29 UTC
Created attachment 19691 [details]
adb ps shell
Comment 13 RobertN 2017-02-02 06:31:15 UTC
Android Studio debug session output using the same physical phone:

02/01 22:21:46: Launching Application
$ adb push /Users/sushi/code/github/custom-tabs-client/Application/build/outputs/apk/Application-debug.apk /data/local/tmp/org.chromium.customtabsclient.example
$ adb shell pm install -r "/data/local/tmp/org.chromium.customtabsclient.example"
        pkg: /data/local/tmp/org.chromium.customtabsclient.example
Success

$ adb shell am start -n "org.chromium.customtabsclient.example/org.chromium.customtabsclient.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: org.chromium.customtabsclient.example | org.chromium.customtabsclient.example.test
Waiting for application to come online: org.chromium.customtabsclient.example | org.chromium.customtabsclient.example.test
Connecting to org.chromium.customtabsclient.example
Connected to the target VM, address: 'localhost:8601', transport: 'socket'
I/art: Late-enabling -Xcheck:jni
I/art: Debugger is no longer active
I/System.out: Sending WAIT chunk
W/ActivityThread: Application org.chromium.customtabsclient.example is waiting for the debugger on port 8100...
I/art: Debugger is active
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1446)
I/InstantRun: Instant Run Runtime started. Android package is org.chromium.customtabsclient.example, real application class is null.
~~~
Comment 14 Marius Ungureanu 2017-02-14 07:57:27 UTC
@Greg, any update?
Comment 15 Greg Munn 2017-02-14 15:20:05 UTC
Sorry, I was away last week. I will try to see if the ps output has odd formatting. in the meantime I did ask QA to obtain a device.
Comment 16 Greg Munn 2017-02-14 22:18:20 UTC
I think perhaps we might need output from logcat, either from `adb logcat` or from the device log in XS.
Comment 17 Greg Munn 2017-03-24 17:58:15 UTC
Robert, did you manage to get logcat logs for this. I'm still trying to get devices in QA for testing this locally.
Comment 18 RobertN 2017-03-26 00:56:16 UTC
@GregMunn Sorry I did not know you were waiting on something from me. 

Just need a logcat capture from a debug attempt on that phone?
Comment 19 Greg Munn 2017-03-27 14:41:53 UTC
At this stage Robert, yes.
Comment 20 RobertN 2017-03-28 04:15:30 UTC
Xamarin Studio 6.2 & Visual Studio for Mac Preview Version Preview 5 (7.0 build 1659)
Xamarin.Android Version: 7.2.0.2 (Visual Studio Enterprise)

Logcat output as attachment (package name = "com.sushhangover.debugz716blb01_foo")

Re-tested debugging from latest Android Studio 2.3, works fine...

   Android Studio 2.3 Build #AI-162.3764568, built on February 24, 2017
   JRE: 1.8.0_112-release-b06 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o


Application Output pad / Visual Studio for Mac Preview Version Preview 5 (7.0 build 1659)

	Forwarding debugger port 8826
	Detecting existing process
	> am start -n "com.sushhangover.debugz716blb01_foo/md5e7bc80caae15740257bf54603b7a9bd0.MainActivity"
	> Starting: Intent { cmp=com.sushhangover.debugz716blb01_foo/md5e7bc80caae15740257bf54603b7a9bd0.MainActivity }

	User assembly '/Users/sushi/Projects/DebugZ716BLB01_foo/DebugZ716BLB01_foo.UITests/bin/Debug/DebugZ716BLB01_foo.UITests.dll' is missing. Debugger will now debug all code, not just user code.
	[art] Late-enabling -Xcheck:jni
	[monodroid] Creating public update directory: `/data/data/com.sushhangover.debugz716blb01_foo/files/.__override__`
	[monodroid] Using override path: /data/data/com.sushhangover.debugz716blb01_foo/files/.__override__
	[monodroid] Using override path: /storage/emulated/0/Android/data/com.sushhangover.debugz716blb01_foo/files/.__override__
	[monodroid] Trying to load sgen from: /data/data/com.sushhangover.debugz716blb01_foo/files/.__override__/libmonosgen-2.0.so
	[monodroid] Trying to load sgen from: /storage/emulated/0/Android/data/com.sushhangover.debugz716blb01_foo/files/.__override__/libmonosgen-2.0.so
	[monodroid] Trying to load sgen from: /data/app/com.sushhangover.debugz716blb01_foo-1/lib/arm/libmonosgen-2.0.so
	[monodroid] Trying to load sgen from: /data/data/com.sushhangover.debugz716blb01_foo/files/.__override__/links/libmonosgen-2.0.so
	[monodroid-debug] Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8826,server=y,embedding=1
Comment 21 RobertN 2017-03-28 04:21:16 UTC
Created attachment 20926 [details]
logcat debug session

package name = com.sushhangover.debugz716blb01_foo
Comment 22 Greg Munn 2017-04-07 20:03:31 UTC
Thanks Robert.

We also got a hold of device today as well. From what I can see so far is that the tcp connection we try to make fails which I can see from Terminal as:

> telnet 127.0.0.1 8848
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> Connection closed by foreign host.

compared to a device that works:

> telnet 127.0.0.1 8847
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> DWP-Handshake

We appear to make the connection, but it is terminated. 

This results in

> {System.IO.IOException: DWP Handshake failed.   at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_delegate_end_invoke (object,intptr)   at (wrapper delegate-end-invoke) <Module>:end_invoke_VirtualMachine__this___IAsyncResult (System.IAsyncResult…}

for which XS will retry the connection.

What is not clear is why the connection is interrupted.