Last Comment Bug 876636 - (tb-debugger) [GSoC 2013] Make Firefox Developer Tools compatible to Thunderbird [meta]
(tb-debugger)
: [GSoC 2013] Make Firefox Developer Tools compatible to Thunderbird [meta]
Status: RESOLVED FIXED
: meta
Product: Thunderbird
Classification: Client Software
Component: General (show other bugs)
: unspecified
: All All
-- normal with 3 votes (vote)
: ---
Assigned To: Philipp Kewisch [:Fallen]
:
:
Mentors:
Depends on: 875104 891003 897564 899971 777674 remote-inspector 825039 870081 872897 880511 880930 881235 881468 883311 883342 884805 895180 897476 898278 899006 914077 915444 936946
Blocks:
  Show dependency treegraph
 
Reported: 2013-05-28 03:32 PDT by Philipp Kewisch [:Fallen]
Modified: 2015-05-16 04:52 PDT (History)
27 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
Screenshot - Web Console Working (488.22 KB, image/png)
2013-07-24 07:10 PDT, Philipp Kewisch [:Fallen]
no flags Details
Screenshot - Network Monitor Working (531.52 KB, image/png)
2013-07-24 07:11 PDT, Philipp Kewisch [:Fallen]
no flags Details
Screenshot - Style Editor Working (339.70 KB, image/png)
2013-07-24 07:14 PDT, Philipp Kewisch [:Fallen]
no flags Details
Screenshot - Profiler Working (414.82 KB, image/png)
2013-07-24 07:17 PDT, Philipp Kewisch [:Fallen]
no flags Details
Screenshot - Inspector Working (477.21 KB, image/png)
2013-09-11 16:38 PDT, Philipp Kewisch [:Fallen]
no flags Details
Screenshot - App Manager Working (335.17 KB, image/png)
2013-09-11 16:39 PDT, Philipp Kewisch [:Fallen]
no flags Details
Screenshot - Scratchpad Working (313.97 KB, image/png)
2013-09-11 18:03 PDT, Philipp Kewisch [:Fallen]
no flags Details
Screenshot - Extension Options (46.91 KB, image/png)
2013-09-14 10:43 PDT, Philipp Kewisch [:Fallen]
no flags Details

Description User image Philipp Kewisch [:Fallen] 2013-05-28 03:32:50 PDT
This bug is to track progress on my GSoC Project to integrate the Firefox devtools into Thunderbird either directly or via remote connection.

I propose to modify Thunderbird to allow using all current remote features of the Mozilla Developer Tools. This includes the web console, debugger, style editor and network monitor. The key difference between my proposal and the past solutions is that no extra UI is needed within Thunderbird which might end up breaking because Firefox-specific features are being used. Instead, I will ensure the existing components are fully free of Firefox specific code and write the wrapper layer needed to make use of the backend components.
Comment 1 User image Philipp Kewisch [:Fallen] 2013-05-30 12:34:13 PDT
I was just about to look into how to do this myself when I saw a review for bug 870081 pop up. This will make things much easier for creating a mail actor.
Comment 2 User image Philipp Kewisch [:Fallen] 2013-05-31 11:00:06 PDT
It would be nice to have bug 805526 fixed so we can also have a remote inspector
Comment 3 User image Philipp Kewisch [:Fallen] 2013-06-03 02:05:31 PDT
So, here is my first update and a firm plan on how I would like to go about things. I have spent the last days reading all the toolkit devtools code to find out what possibilities we have and what needs to be done. The devtools team really deserves something shiny for their architecture and thanks to the existence of b2g their code is written to work with more than one application.

The dates are oriented at the GSoC dates and rather optimistic. I believe I will be able to achieve some of these milestones earlier.

Milestone 1: June 3rd - June 30th
* Add UI to Thunderbird to start the remote debugger (Tools menu)
* Initialize the debugger server correctly, allow remote connections
* Refactor chrome debugger and browser actor
  (this was my plan, but is now fixed by bug 870081)
* Make chrome debugger work for the main window
* Make sure it also works for secondary windows
* Add a "tab" actor per displayed email to be able to access content documents

Milestone 2: July 1st - July 29th
* Make WebConsoleActor/StyleEditorActor code in toolkit independent of window
* Hook up the web console to Thunderbird's console via WebConsoleActor
* Hook up the style editor to Thunderbird via StyleEditorActor

-- Midterms --

Milestone 3: August 2nd - August 16th
* Make the profiler work for chrome code
* Make sure the profiler works for content code (if needed?)
* Hook up the network monitor

Milestone 4 (bonus): August 2nd - September 9th
* Investigate the possibility to add imap connections to the network monitor
* Find out if the gcli actor makes sense for Thunderbird and is remoteable
  - Alternatively, consider adding the gcli to Thunderbird itself.
* Check if Inspector is ready for remote support yet
* Integrate Scratchpad

Milestone 5: September 10th - September 23rd
* Clean up UI
* Complete writing tests
Comment 4 User image Philipp Kewisch [:Fallen] 2013-06-10 06:30:29 PDT
First success with the debugger on bug 881235! That patch will allow chrome debugging on the main process. Things are going much better than I even anticipated. Next up I will hook up any content windows to the "remote tabs" section of the debugger, this should be a matter of enumerating the windows, searching for content windows and yielding an actor grip for each of them.
Comment 5 User image Philipp Kewisch [:Fallen] 2013-06-11 05:42:52 PDT
bug 875104 will be actually using the tabListChanged notification. Note to self: check if the Thunderbird tab list implementation still works afterwards.
Comment 6 User image Philipp Kewisch [:Fallen] 2013-06-13 10:39:11 PDT
Some other random notes from discussion today:

* As a side note, see this project: https://wiki.mozilla.org/Sepsis
* The code for the debugger is landed in mail/components/debugger, but it would be
  even better if this were in mailnews so that Seamonkey can also make use of it
* Going one step further, it would be nice to (also) have an extension that works
  on all xulrunner type applications. Creating the extension from the source
  directory would make things easier.
* There is no need to create Makefile.in's with no directives other than the
  includes


Also, I've blogged about the matter here:

http://kewisch.wordpress.com/2013/06/13/the-thunderbird-remote-debugger-is-alive/
Comment 7 User image Philipp Kewisch [:Fallen] 2013-06-14 13:35:17 PDT
Milestone 1: June 3rd - June 30th
=================================

> * Add UI to Thunderbird to start the remote debugger (Tools menu)
> * Initialize the debugger server correctly, allow remote connections
> * Make chrome debugger work for the main window
Fixed by bug 881235

> * Refactor chrome debugger and browser actor
As mentioned, fixed by the devtools team in bug 870081

> * Make sure it also works for secondary windows
I've tested this and it generally works. If you open the window, set the breakpoint, then its triggered as expected. If you close the window and open it again, the breakpoint is not triggered again. I've filed bug 883342 for this, it also fails for Firefox.

> * Add a "tab" actor per displayed email to be able to access content
> documents
Will be fixed by bug 883311.

I've also fixed two very trivial bugs in the devtools code. I will monitor bug 883342 and possibly find a solution for this, but aside from that I feel Milestone 1 is completed.

Since there is still some time before the next milestone is scheduled, I will take the time to figure out how to best proceed w.r.t Seamonkey and xulrunner. It would be nice to be able to have it work with those kinds of apps too.
Comment 8 User image Philipp Kewisch [:Fallen] 2013-06-18 16:23:02 PDT
bug 825039 will solve Milestone 4's integrate scratchpad, it will be possible to execute scratchpad in the context of the current debugger, which will mean Thunderbird.
Comment 9 User image Philipp Kewisch [:Fallen] 2013-06-18 23:56:20 PDT
Calendar uses a lot of XBL, it would be nice to have bug 777674. Looks like its still a little bit away though.
Comment 10 User image Philipp Kewisch [:Fallen] 2013-06-19 08:17:49 PDT
Not adding this as a dependency, but just another interesting use case: bug 809561.
Comment 11 User image Philipp Kewisch [:Fallen] 2013-07-01 02:52:41 PDT
Just in case you didn't read all dependent bugs: code will likely move into an extension in bug 884805.
Comment 12 User image Philipp Kewisch [:Fallen] 2013-07-24 07:10:28 PDT
Created attachment 780383 [details]
Screenshot - Web Console Working
Comment 13 User image Philipp Kewisch [:Fallen] 2013-07-24 07:11:45 PDT
Created attachment 780385 [details]
Screenshot - Network Monitor Working

The network monitor just works out of the box!
Comment 14 User image Philipp Kewisch [:Fallen] 2013-07-24 07:14:36 PDT
Created attachment 780389 [details]
Screenshot - Style Editor Working
Comment 15 User image Philipp Kewisch [:Fallen] 2013-07-24 07:17:56 PDT
Created attachment 780391 [details]
Screenshot - Profiler Working
Comment 16 User image Mike Conley (:mconley) 2013-07-24 07:19:29 PDT
\o/ Fantastic work, Philipp.

This is excellent blog fodder, btw.
Comment 17 User image Philipp Kewisch [:Fallen] 2013-07-24 07:32:01 PDT
Milestone 2: July 1st - July 29th
=================================

> * Make WebConsoleActor/StyleEditorActor code in toolkit independent of window
Patch is up in bug 880511.

> * Hook up the web console to Thunderbird's console via WebConsoleActor
> * Hook up the style editor to Thunderbird via StyleEditorActor
Both actors added as part of bug 897476. Also, in Devtools bug 872897 I fixed a problem with imported style-sheets which are quite common in Lightning.

> -- Midterms --
Coming right up :)

> Milestone 3: August 2nd - August 16th
> * Make the profiler work for chrome code
Part of bug 897476.

> * Make sure the profiler works for content code (if needed?)
I don't have a good content tab to test this on, but given hooking up the profiler was just a matter of adding the actor, I assume this works.

> * Hook up the network monitor
Works out of the box, yay!
Comment 18 User image Philipp Kewisch [:Fallen] 2013-07-24 07:32:56 PDT
(In reply to Mike Conley (:mconley) from comment #16)
> \o/ Fantastic work, Philipp.
> 
> This is excellent blog fodder, btw.

Definitely, I will write a blog post on these soon :-)
Comment 20 User image Philipp Kewisch [:Fallen] 2013-07-26 02:15:06 PDT
Ok, let me tell you a little about the post-midterm milestones:

> Milestone 4 (bonus): August 2nd - September 9th
> * Investigate the possibility to add imap connections to the network monitor
Filed bug 897564. This could be pretty tricky and might exceed the scope of a GSoC project. I haven't confirmed this with anyone, but it looks to me like this needs to be done on a per-channel basis, implementing nsITraceableChannel on the mock imap channel, somehow ignoring the cached entries and using the observer service to notify when imap requests are being made. The alternative would be a general mechanism that allows tracking any network connections, this goes down pretty deep into gecko.

> * Find out if the gcli actor makes sense for Thunderbird and is remoteable
>   - Alternatively, consider adding the gcli to Thunderbird itself.
Yes, gcli is remoteable, but it contains _a lot_ of Firefox specific code and dependencies. I've filed bug 898278.

> * Check if Inspector is ready for remote support yet
bug 805526, not ready yet, but dcamp is working on it.

> * Integrate Scratchpad
It will be possible to use scratchpad remotely, likely without any extra Thunderbird work, when bug 895180 is fixed.

> Milestone 5: September 10th - September 23rd
> * Clean up UI
> * Complete writing tests
I'm going to use this milestone for completing the extension packaging work. The idea is to take the code currently in dbg-messenger-overlay.js and package it into a module. Then I can just call these methods from either the builtin overlay or the extension's bootstrap.js. I will also refactor the toolkit DebuggerServer's addBrowserActors() to something like addCommonActors() which contains all actors that are supposed to work regardless of the app and then just call that from our init code. This way, if an actor is added in the future it will automatically work with Thunderbird too.

Given there is not much code on the Thunderbird side, the number of tests won't really be extensive, but I guess I could add a test that starts the debugger server, makes sure its initialized and that there are no console error messages.
Comment 21 User image Philipp Kewisch [:Fallen] 2013-07-30 05:53:57 PDT
Fixing bug 899006 will allow us to slim down the code in mail/ so that any new actor that is added by the devtools team will automatically be available in Thunderbird.
Comment 22 User image Philipp Kewisch [:Fallen] 2013-09-03 07:03:04 PDT
Hello Folks,

sorry I haven't given you an update lately. Here are some details:

I'm working on getting the changes in bug 899006 through, this has been delayed a bit. As mentioned previously, this will make it exceedingly easy to manage the devtools from Thunderbird and makes this project futureproof.

Regarding showing IMAP connections, mconley and I have agreed that this has fallen out of scope. To do it right, I would need to implement a general way to make network connections within the Mozilla platform traceable, which requires an experienced Mozilla network team member to do correctly or at least could be a gsoc project on its own. The devtools team has set the respective bug (see above) to P3, so maybe this is something that could be done as joint effort. I will definitely stay on this even after GSoC.

Next up is gcli. I've already mentioned that its possible, but I haven't given any details yet. With the code I have now, its possible to connect gcli to a remote Thunderbird instance and send commands. I've been able to work around all visible error messages but am now at a point where there are no error messages but sending commands doesn't bring a response yet. I will continue to debug this.

Scratchpad is going forward too, there is a patch from bbenvie that adds a scratchpad tab to the debugger toolbox and uses the remote connection. Its an early WiP patch, but it looks very promising.

I have postponed the extension packaging until bug 899006 is fixed since it will greatly influence how the code looks like.

3 of 4 Milestones have already been reached and the remaining stuff doesn't look so complicated, therefore I am confident that I can reach all milestones in time for the finals.
Comment 23 User image Philipp Kewisch [:Fallen] 2013-09-11 16:38:51 PDT
Created attachment 803378 [details]
Screenshot - Inspector Working
Comment 24 User image Philipp Kewisch [:Fallen] 2013-09-11 16:39:22 PDT
Created attachment 803379 [details]
Screenshot - App Manager Working
Comment 25 User image Philipp Kewisch [:Fallen] 2013-09-11 18:03:07 PDT
Created attachment 803426 [details]
Screenshot - Scratchpad Working

Scratchpad works great with the WIP patch in bug 895180!
Comment 26 User image Magnus Melin 2013-09-12 02:32:23 PDT
w00t!
Comment 27 User image Mike Conley (:mconley) 2013-09-12 08:12:36 PDT
This is the greatest. :)
Comment 28 User image Philipp Kewisch [:Fallen] 2013-09-14 10:43:47 PDT
Created attachment 804913 [details]
Screenshot - Extension Options
Comment 29 User image Philipp Kewisch [:Fallen] 2013-09-14 10:57:11 PDT
Ok, I think I am set for the pencils down date. Here's the status:

Patches for bug 880930, bug 884805, bug 897476 and bug 915444 are in review. This covers everything from my side, execpt for the gcli integration.

During creating the gcli patch I have been blocked by another bug in the gcli code where I couldn't continue. I don't have a bug for this, but I was promised it would be fixed soon. Aside from that, we have decided gcli is no longer a target for the end of the SoC. There is really a lot of code in browser/ that should be in toolkit/. I have started to move some of this code, but its not easy to separate everything. As gcli is not part of the toolbox but has its own connection mechanisim, I think its more of a secondary goal.

As you can see in the above screenshots, inspector and scratchpad also work nicely. There are still some quirks in the inspector support, but I believe these will be fixed by the devtools team anyway.

I will create another blog post to wrap things up on Wednesday.
Comment 30 User image Philipp Kewisch [:Fallen] 2013-09-14 10:57:45 PDT
Mike, if there is anything else you think I should cover, please let me know!
Comment 31 User image Philipp Kewisch [:Fallen] 2013-09-22 14:38:38 PDT
Here is the wrapup blog post: http://kewisch.wordpress.com/2013/09/22/thunderbird-developer-tools-wrapup/

Marking this bug as FIXED, I will continue my work after the Summer of Code to make sure nothing breaks and new features in the Firefox Developer Tools are also available in Thunderbird.

Thanks to everyone who supported me during the time!
Comment 32 User image David Rees 2013-09-24 20:53:04 PDT
Very, very, very cool. Sorry if I missed it, but are the new install steps? You mention an extension in the wrapup post, but didn't give the link or updated install steps from your first post. Also, what versions are required? Thanks!
Comment 33 User image David Rees 2013-09-26 21:33:41 PDT
I just tried the install instructions from your first blog post. All the steps went fine, but after I click connect Firefox never makes it past the "Connect to remote device, Connecting…" page. I ran wireshark on the loopback and here is the result. I am seeing this with both the 9/24 and 9/26 nightlies on OSX 10.8.5.

124:{
  "from": "root",
  "applicationType": "mail",
  "testConnectionPrefix": "conn2.",
  "traits": {
    "sources": true
  }
}40:{
  "to": "root",
  "type": "listTabs"
}760:{
  "error": "unknownError",
  "message": "error occurred while processing 'listTabs: TypeError: tabList.getList is not a function\nStack: RootActor.prototype.onListTabs@resource://gre/modules/devtools/dbg-server.jsm -> resource://gre/modules/devtools/server/main.js -> resource://gre/modules/devtools/server/actors/root.js:233\nDSC_onPacket@resource://gre/modules/devtools/dbg-server.jsm -> resource://gre/modules/devtools/server/main.js:1018\n@resource://gre/modules/devtools/dbg-server.jsm -> resource://gre/modules/devtools/server/main.js -> resource://gre/modules/devtools/server/transport.js:198\n@resource://gre/modules/devtools/dbg-server.jsm -> resource://gre/modules/devtools/server/main.js -> resource://gre/modules/devtools/DevToolsUtils.js:72\n"
}
Comment 34 User image David Rees 2013-09-26 21:45:37 PDT
Just in case it was caused by the bump of Firefox nightly to 27 I also tried the 9/14 nightlies (26.0a1 2013-09-14). I'm seeing the same problem. Thx.
Comment 35 User image Philipp Kewisch [:Fallen] 2013-09-27 00:38:52 PDT
Please see the dependent bugs. Not everything has been checked in yet, the error you describe is caused by an API change in the developer tools protocol. So at the current moment the steps are: 1) build thunderbird 2) apply remaining patches 3) use latest ffx nightly. This will of course get easier, I will do another blog post when its just a matter of using the latest nightly versions.

You don't need the extension for Thunderbird, its just useful for other Apps like XULRunner or possibly Seamonkey (although I think they were doing something similar as I am for Thunderbird). I have some end user documentation here:

https://wiki.mozilla.org/User:Kewisch/Thunderbird_Developer_Tools_Documentation

It will be moved to MDN when we figure out a good place to put it.
Comment 36 User image David Rees 2013-09-28 12:17:14 PDT
Success! I applied bug 897476 and bug 915444 and built tbird and I am now able to inspect/debug. Thank you!
Comment 37 User image Dave Huseby [:huseby] 2014-05-26 11:46:17 PDT
What's the current status of this work?  Why hasn't this made it into the release version of tbird?
Comment 38 User image Matt 2014-05-26 15:30:44 PDT
(In reply to Dave Huseby [:huseby] from comment #37)
> What's the current status of this work?  Why hasn't this made it into the
> release version of tbird?

Did you read the blog posts referenced.  This bug is closed because it is complete. The only Thunderbird UI change was the allow remote debugging entry on the tools menu.  The rest of the debugging process occurs from Firefox.
Comment 39 User image Philipp Kewisch [:Fallen] 2014-05-26 23:27:00 PDT
Pure debugging is available on Thunderbird 24 already, the full suite was added in betas shortly after and is therefore also part of Thunderbird 31. Please see the dependent bugs for the real work. For a guide on how to make it work see:

https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging/Thunderbird
Comment 40 User image konstantin 2015-02-12 06:00:41 PST
Philipp, dude , thank you for that work, no really I mean thank you.

Note You need to log in before you can comment on or make changes to this bug.