Repository navigation
Description
Hi! As part of the Outreachy project this year I will be working on supporting DevTools again, making them work with the current versions of Servo and Firefox. This is a meta issue that gathers all of the information in a place that can be easily referenced, and in which updates on the state of the project can be provided. Please do add anything you might consider useful or necessary to the discussion!
Roadmap
- Determine the current state of DevTools support
- Show Servo's tabs and processes, based on the work from fabricedesre@0c41bf4, in DevTools: Display tabs and processes #32475
- Restore Tab inspector
- Create a Watcher Actor for Tabs, in DevTools: Implement watcher actor #32509
- The DevTools inspection view is visible
- Console functionality
- Javascript REPL
- Console messages and errors, in DevTools: Display console messages and errors #32727
- Restore layout inspector
- Build and inspect HTML DOM tree, in DevTools: Show HTML tree #32655
- Fix whitespace issue, in DevTools: Inline text and clean whitespace #32884
- Include inline contents in the nodes (paragraph text, ...), in DevTools: Inline text and clean whitespace #32884
- Add, modify and remove tag attributes, in DevTools: Allow modification of attributes #32888
- CSS Styling
- Add applied and computed properties to document nodes, in DevTools: Inspect node styles #33025
- List all CSS properties, in DevTools: Inspect node styles #33025
- Layout: box
- Grid and flex (future)
- Create a Watcher Actor for Tabs, in DevTools: Implement watcher actor #32509
- Cleaning up the code
- Remove camel case variable names, in DevTools: Replace camel case variable names #32726
- Look into JSON replies
- Check for caching opportunities and other performance improvements
- Full documentation
- Improve comments on actors and their functions
- Add debugging instructions to Servo Book, in DevTools guide book#16
- Maintaining guide
Current state
The DevTools connection prompt is functional and Firefox can find Servo. Tabs with their titles are listed in the overview. Now you can see the inspector window with the DOM tree and use the console to run Javascript on Servo. Support for css styling is being worked on.
There is some progress in the HTML department (Servo on the left, Firefox on the right). You can start to see the DOM structure and modify tags.
Open Issues
Recent (~2023-24)
These are the more relevant to restoring support for DevTools. It was broken around June 2023 and it is confirmed not to work properly from Firefox 110 onward.
#29831 : Main issue that details the broken support and previous attempts to fix it.
Mid (~2020-2022)
These are from a time where DevTools worked, but these issues were never presumably solved, so if we get it up and running again it may be good to look if they are still relevant.
#26667 : Reporting unhandled promise rejections didn't work
#26368 : Errors navigating DevTools
#26323 : Unreported network events
#25119 : Make it so DevTools can be started later
Older (~2013-2019)
Outdated but interesting issues.
#8973 : Old experiment to create a standalone HTML UI of the Firefox DevTools
#4957 : Add support for the debug timeline
Previous work
This section only includes relevant prs since DevTools were broken last year.
#32227 : Great pr from @oSoMoN that fixes how Servo is displayed in the about:debugging Firefox page and removes some warnings.
fabricedesre@0c41bf4 : Work done by @fabricedesre to update the DevTools implementation to conform to the new Firefox changes. It may be a good place to start.


Activity
eerii commentedon Jun 14, 2024
How to debug RDP messages
One key part of restoring the DevTools support is correctly sending the proper messages through the RDP (remote debugging protocol). However, the message fields for each action between actors are not well documented, making it tricky to know exactly what to send.
Servo can easily show the messages it sent and the ones it received from the DevTools server. It's as easy as enabling the correct logging level when running the program.
RUST_LOG="error,devtools=debug" ./mach run --devtools=1234This is very useful to see if the message is properly formatted, but what about creating new messages? How could you find the correct fields and format? One idea is to run another instance of Firefox, which fully supports the entire protocol as both a server and a client, and see what happens between the two.
Starting another Firefox instance
To connect remotely via DevTools you need to go to
about:debugging, just like you would for testing Servo. Here you can connect to multiple instances of Firefox (desktop or mobile) and other supported browsers. If you have an Android phone, you can connect it via USB and it should show up. For this example, I will be running another instance of Firefox on my laptop, but the process should be similar with a phone.One restriction that Firefox has is that you can't run multiple instances of the same profile. There are several options here, either downloading something like Firefox Developer Edition, which comes with another profile, or simply navigating to
.mozilla/firefox(in Linux) and making a copy of your profile with another name. You can find more about profiles here.Now we can run another instance of Firefox with the debugging server enabled (this is important!) using this command:
firefox --new-instance --start-debugger-server 1234 --profile ~/.mozilla/firefox/NAMEAnother window should pop up, and it likely has a robot on the search bar that indicates that we are running it in debugging mode.
Before being able to connect to it, there are a few settings that we have to change in the new profile. This only needs to be done and it can be done either modifying
user.jsor going toabout:config(on the new browser window) and searching for each option.Inspecting the new instance
Going back to the first browser, in
about:debuggingwe can add a connection to the new instance that we created. Under Setup -> Network Location, addlocalhost:1234(the same port as before). This is the same setup that needs to be done when debugging Servo.Now, with the other instance still running, we can click Connect in the sidebar. It should show information about our other browser, like tab names and workers.
Intercepting the messages
The messages between DevTools and the browser are sent as JSON payloads through a websocket. One would think that the browser console would be able to show them. In Multiprocess mode and targeting the browser itself and not the webpage it does indicate that there are messages being sent, but they don't seem to contain the relevant data. I also tried logging with
MOZ_LOGbut it wasn't very fruitful either.Wireshark is a very useful network packet analyzer, and we can configure it to listen to this traffic. Open Wireshark and select the loopback intercept. This should start logging packets sent inside of your local network.
This can be very messy, specially if you have some other services open, but we can refine it easily by filtering by the specified port and only showing JSON:
tcp.port == 1234 && tcp.payload.Here you can start seeing the messages and the responses. For example, this experiment started with me trying to implement the response to the
getWatchermessage. The way it is shown in Wireshark is not very easy to inspect, and it has a lot of extra information. Thankfully, Wireshark can export the packets' readable text, or you can use a tool liketcpdump -A -r capture.pcapngto batch show all of the decoded packet descriptions.Finally, I want to mention geckordp, a complete implementation of the DevTools remote protocol in python which had very useful insights on how to inspect network packets and the general API design.
Updated current progress: After being able to check the correct message format, I am working on implementing a Watcher Actor so that inspecting a webpage is functional again!
eerii commentedon Jul 2, 2024
Update on debugging messages
Following up on the previous comment, I made the workflow of debugging messages a bit more straightforward. Launching wireshark, creating a capture, saving it, processing it and trying to read it every time was a bit cumbersome, so I created a small python script to automate the process. It can either take an existing
.pcapfile or launchtshark(wireshark's command line tool) with the appropriate parameters to start listening. Then, it processes the JSON, separates messages that are batched on the same call and pretty prints it so it is more legible. It can also filter by word or by a range of messages. Here is a small preview:There are still some edge cases with some messages that are so big that they are spread across multiple packets, but it is enough for now. It has proven very useful to know the format of the needed messages. Here is the source code:
Finally, I was going to add a function where it converted the JSON objects into rust structs, but I found out this awesome website that automatically does it following Serde conventions and properly renaming fields, and I don't want to reinvent the wheel.
That's it for now! I am working on implementing the inspector again, currently I am adding all of the available CSS properties so that you can edit them. Sending the source code of the page is up next c:
jdm commentedon Jul 2, 2024
Could you add that script under etc/ so it's easy to find in the future?
eerii commentedon Jul 3, 2024
Absolutely! I will clean it up a bit and open a pull request for it. Thanks for the suggestion.
Edit: I opened #32684
eerii commentedon Apr 9, 2026
I'm going to close this now since support for DevTools has improved quite a bit. There are still issues and tabs that could use better support, but we are tracking those in separate meta issues (i.e. #36027 and #39858). I feel like this one was mostly related to the scope of the initial Outreachy internship. Also, the documentation from the comments is already in the book.