Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23628] Android: Unable to debug an application with run-on-main-thread set to true

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-09-29T06:04:21.000+0000
Affected Version/sRelease 5.4.0
Fix Version/sRelease 6.0.0
ComponentsAndroid, Hyperloop
Labelsnotable, qe-5.4.0
ReporterEwan Harris
AssigneeChristopher Williams
Created2016-07-12T17:51:53.000+0000
Updated2018-08-06T17:49:15.000+0000

Description

Description

When debugging a project with run-on-main-thread enabled the breakpoints will not be hit.

Steps to reproduce

Create an alloy application from Studio with services disabled

Place a breakpoint in index.js on line 2

Debug the application on device

Press the 'Hello World' label

Enable hyperloop for the project by clicking the 'Enable Services' button or add <property name="run-on-main-thread" type="bool">true</property> to the tiapp.xml

Debug the application

Press the 'Hello World' label

Actual result

The breakpoint is hit in step 4 but not in step 7

Expected result

The breakpoint should be hit in step 4 and 7

Comments

  1. Eric Wieber 2016-07-12

    Removing the 'Android' prefix/component as I encounter this on iOS as well.
  2. Wilson Luu 2016-07-13

    [~cng], Here are the findings: *iOS:* ||jscore||main thread||results|| |true|true|builds, but breakpoint is not hit| |false|true|*builds, can hit breakpoint*| |anything|false|project fails to build| *Android:* ||jscore||main thread||results|| |true|true|builds, but breakpoint is not hit| |false|true|builds, but breakpoint is not hit| |anything|false|builds, but breakpoint is not hit|
  3. Ashraf Abu 2016-07-13

    Able to reproduce this on Android with 5.4.0v20160712013704. With hyperloop, debug doesn't work. Without hyperloop, it works. <property name="run-on-main-thread" type="bool">true</property> doesn't seem to make a difference for Android. Tested with Android 6.0 on Nexus 6.
  4. Chee Kiat Ng 2016-07-13

    Thanks [~msamah]. So it's a known matter that Hyperloop doesn't work with debugger for iOS if use-jscore-framework is set to true. By default, it is set to false. What's new to me was that Hyperloop doesn't work with debugger for Android. For this release, we just need to make it known to developers that currently we have no support for hyperloop with debugger. [~bimmel] Definitely worth a mention in the Beta release notes. And we need to address these debugger issue soon for both Android and iOS in the next releases. [~ingo][~sdavenport][~bgrantges@appcelerator.com][~jkneen] please note.
  5. Ashraf Abu 2016-07-13

    [~cwilliams] Seems like the hyperloop is causing the issue for Android. Any thoughts?
  6. Christopher Williams 2016-07-13

    I don't believe hyperloop itself is causing the debugger to break. It's running on a single thread (which is required for hyperloop) that is causing the issue. We likely need to rewrite the debugger for Android to work on a single thread like Hans/Angel did for iOS. Please also note that the V8 update also plays a role in that we likely need to update how we hook the debugger there. - https://github.com/appcelerator/titanium_mobile/blob/master/android/runtime/v8/src/native/V8Runtime.cpp#L256 - https://github.com/nodejs/node/blob/master/src/debug-agent.cc - http://v8.paulfryzel.com/docs/master/classv8_1_1_debug.html - https://groups.google.com/forum/#!topic/v8-users/pS5tgGXzzHY - https://chromium.googlesource.com/v8/v8/+/1e4822ffed805d9cbb2a47cc9453aef06f3dfaca/src/debug-agent.cc - http://blog.joshgav.com/node/debugging/2016/02/04/Node-Debug-Architecture.html - http://stackoverflow.com/questions/28289538/how-to-use-chrome-debugger-with-v8-on-android - https://github.com/buggerjs/bugger-v8-client/blob/master/PROTOCOL.md Long story short? Running on a single thread likely broke our debugger, so it probably needs to be rewritten. V8 moved their builtin debug agent/relay out, so we need to add an impl back in anyways.
  7. Christopher Williams 2016-08-02

    This is fixed on Android with 6.0+ with the latest master build of the SDK and development build of Studio. Not sure how we want to handle this, since we likely need separate fixes for iOS and Android...
  8. Ashraf Abu 2016-08-03

    I think it is acceptable for debug in hyperloop to not work in 5.4.0 for Android and for the user to expect it to work in 6.0+
  9. Chee Kiat Ng 2016-08-03

    Yes that's fine. I'll change this ticket to Android exclusive. Similarly for iOS it's unable to debug with hyperloop and jscore-framework enabled. That'll be a separate ticket. Hyperloop + jscore-framework disabled works ok.
  10. Ashraf Abu 2016-08-03

    TIMOB-23638 has fixed the debugger. Can be tested with the latest master for Ti SDK as well as latest studio https://github.com/appcelerator/titanium_studio/pull/793 which you can take from nightly builds (4.8.0.201608020921) http://preview.appcelerator.com/appc-studio/
  11. Lokesh Choudhary 2016-09-09

    I am still not able to hit the breakpoint with hyperloop enabled & with run-on-main-thread , true & false. Reopening as of now. Environment: Appc Studio : 4.8.0.201609061702 Ti SDK : 6.0.0.v20160908065418 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.6 Appc NPM : 4.2.8-6 Appc CLI : 6.0.0-38 Node: 4.4.4 Nexus 6 - Android 6.0.1 Hyperloop module: 2.0.0
  12. Christopher Williams 2016-09-15

    Well I can confirm it's broken. Not sure what changed or why yet. In local debugging I'ms being some really weird behavior where Studio's own socket-to-socket connection internal doesn't connect up properly, and I'm stumped as to why.
  13. Christopher Williams 2016-09-15

    Ugh, this ticket sucks. So for whatever reason the ugly-but-working code where we'd open a server socket on localhost and connect to it from separate Java threads in Studio is no longer working. I managed to abstract the code enough to move away form using sockets to using piped streams to achieve the same effect, but that's going wonky because piped streams in java use hacks to check if the reading and writing threads are alive to check if the pipe is "broken". So now I'm trying to figure out how to avoid the Thread hell we have and still get the pipes to work. If not, I don't really know how to fix this without ripping apart a lot of code.
  14. Christopher Williams 2016-09-21

    I'm finally making progress once I chucked the idea of salvaging Max's code. I'm rebuilding the debug model the hierarchy for V8 from scratch (it's the data model used by eclipse for controlling the debugger), while retaining the same API/model id so the Ui should look/feel the same as before. This is the same approach I used for the iOS/JSC debugger. Anyways, I'm still iterating on this, but I do have it connecting to the app, and setting and hitting breakpoints for now. As part of this work, I noticed a bug in the debugger agent I created for the updated Android/V8. I'll be pushing a fix to the SDK for that as well.
  15. Christopher Williams 2016-09-23

    Pushed some NPE fixes to studio3 repo for this: development: https://github.com/aptana/studio3/commit/2537ed0592f5cc631ee739c76c3fb8eb4e377b2a release: https://github.com/aptana/studio3/commit/e052be2a5c5c3982f5edcac5ae9f366379a1c9b8 Here's PRs to fix a debugger bug in 6+ of the SDK: master: https://github.com/appcelerator/titanium_mobile/pull/8428 6_0_X: https://github.com/appcelerator/titanium_mobile/pull/8429 Working on the studio PRs still...
  16. Christopher Williams 2016-09-23

    Studio PR for 'release' branch (Studio 4.8.0/SDK 6.0.0): https://github.com/appcelerator/titanium_studio/pull/818
  17. Kondal Kolipaka 2016-09-29

    Merged into development and release branches.
  18. Lokesh Choudhary 2016-10-13

    [~cwilliams], Does this ticket fix debugging with hyperloop enabled? or just run-on-main-thread? Its not clear from the comments. FYI, It is still failing with hyperloop enabled but works fine with no hyperloop.
  19. Christopher Williams 2016-10-14

    [~lchoudhary] As far as I know it should work with and without hyperloop, and with run-on-main-thread or not. If it's not working with hyperloop specifically, we should probably open a new ticket to investigate that (though I find it very odd that hyperloop itself would play any role whatsoever - the run-on-main-thread required to use hyperloop seems more plausible). Have you tried without hyperloop, but with run-on-main-thread?
  20. Lokesh Choudhary 2016-10-14

    [~cwilliams], Below are my findings, ||Hyperloop|||(/)||(x)||(/)||(x) ||Run on main thread|||(/)||(/)||(x)||(x) ||Debugging Working?|||No||Yes||No||Yes| Environment: Appc Studio : 4.8.0.201610060953 Ti SDK : 6.0.0.v20161013072802 Ti CLI : 5.0.10 Alloy : 1.9.2 MAC El Capitan : 10.11.6 Appc NPM : 4.2.8-7 Appc CLI : 6.0.0-58 Node: 4.6.0 Nexus 6 - Android 6.0.1 Environment : preproduction
  21. Lokesh Choudhary 2016-10-14

    Opened ticket TIMOB-24037 for specific hyperloop issue.
  22. Eric Merriman 2018-08-06

    Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.

JSON Source