Note debugging TImelapse

Brian Burg edited this page Mar 29, 2014 · 10 revisions

Enabling second-level inspector

On OS X, you must adjust some settings for the second-level inspector to work. Enter the following at the command line:

defaults write com.apple.Safari __WebInspectorPageGroupLevel1__.WebKit2ApplicationChromeModeEnabled -bool YES
defaults write com.apple.Safari __WebInspectorPageGroupLevel1__.WebKit2DeveloperExtrasEnabled -bool YES

Logging

WebKit is able to log debug and error information from many sources.

Messages from Web Inspector

Inside Web Inspector, any console.log or console.assert messages will appear in the second-level inspector in a debug build. To make these messages additionally appear in the console (even in release builds), set the following preference:

defaults write com.apple.Safari __WebInspectorPageGroupLevel1__.WebKit2LogsPageMessagesToSystemConsoleEnabled -bool YES

Replay infrastructure

To permanently enable logging messages from the replay infrastructure, set the following preference (OS X):

defaults write -g WebCoreLogging -string "WebReplay"

This can also be used to enable other logging within WebCore by concatenating the log levels with a comma. You can see a list of available levels inside Source/WebCore/platform/Logging.h. Other components such as WebKit2 have separate log levels.

NB. For debugging nondeterminism issues, Brian prefers a wider set of logging that includes network, events, and the page cache. Here's his setting:

defaults write com.apple.WebProcess WebCoreLogging -string "WebReplay,Events,Loading,Network,PageCache,History"

Attaching a debugger

There are several ways to do this (OS X):

  1. Open XCode manually, select "Product > Attach to Process..." from the menu bar.

For OSX 10.8: Attach to WebProcess to debug JavaScriptCore, WebCore, Inspector backend, and the WebProcess-side of WebKit2. Attach to SafariForWebKitDevelopment to debug the UIProcess-side of WebKit2.

For OSX 10.9: Attach to com.apple.WebKit.WebContent.Development to debug JavaScriptCore, WebCore, Inspector, and the WebProcess-side of WebKit2. Attach to SafariForWebKitDevelopment to debug the UIProcess-side of WebKit2. Attach to com.apple.WebKit.Networking.Development to debug the NetworkProcess-side of WebKit2. Note that the WebContent process could be destroyed when navigating between domains, and you will have to re-attach the debugger.

  1. To debug under lldb/gdb, run the script Tools/Scripts/debug-safari, passing --debug or --release. (You can set the default configuration of release or debug using the script Tools/Scripts/set-webkit-configuration.

For more tips, see the debugging section of the WebKit wiki.