Debugging webOS applications

24
Debugging webOS Debugging webOS Applications Applications Steve Lemke webOS Tools Engineering April 23, 2010

description

Steve Lemke takes you through the process of debugging your app.

Transcript of Debugging webOS applications

Page 1: Debugging webOS applications

Debugging webOSDebugging webOSApplicationsApplications

Steve LemkewebOS Tools Engineering

April 23, 2010

Page 2: Debugging webOS applications

About Me

• Tools Engineer at Palm• Palm (webOS) Emulator• Internal and external SDK/PDK tools

• Previously• Palm Computing (acquired by US Robotics)• US Robotics (acquired by 3Com)• 3Com (spun out Palm Inc.)• Palm Inc. (spun out PalmSource)• PalmSource (acquired by Access Systems)

Page 3: Debugging webOS applications

Overview

• General Connectivity• JavaScript Logging• Palm Inspector and WORM• Host Mode for WebKit Inspector• Command Line Debugging• Ares Debugger• Emulator Tips and Tricks• Command Line Tips• Helpful Resources• Q & A

Page 4: Debugging webOS applications

General Connectivity

• IP vs. USB• IP over USB is tricky

• novacom and novaterm• Default target is most recently connected target• Helpful if you realize it; confusing if not• Leave emulator running• Tip: connect device only when needed, then disconnect

• ssh• Built-in to emulator (localhost:5522)• Can be added to device (“pdk-device-install”)• Useful on Windows (Putty)• Can tunnel other ports (but novacom will too)

Page 5: Debugging webOS applications

JavaScript Logging

• Use “Mojo.Log.Info” instead of “console.log”

• Viewing log output:• Good: “novaterm” + “tail -f /var/log/messages”• Better: “palm-log -f com.test.app”• Best: Ares has built-in log viewer

Page 6: Debugging webOS applications

JavaScript Logging

• To enable logging in framework_config.json:• “loglevel”:99 (enable Mojo.Log.info/warn)

• “logEvents”:true (log framework/mouse events)

• “timingEnabled”:true (log scene transition timing)

• Restore default settings before shipping!• “loglevel”:0 (disable Mojo.Log.info/warn)

• “logEvents”:false (no framework/mouse events)

• “timingEnabled”:false (no scene transition timing)

• MUST change system log level to see info/warn on device!• Default is “error” only

• Type: palm-log --system-log-level info

Page 7: Debugging webOS applications

Palm Inspector

• Launch application with “palm-launch -i <appname>”

• Launch “Palm Inspector” app• Type “palm-inspector” on Linux

• Emulator only

Page 8: Debugging webOS applications
Page 9: Debugging webOS applications

Palm WORM

• Launch “palm-worm” app

• Live graphs of:• Total DOM nodes• Open service handles• JavaScript heap usage

• Emulator only

Page 10: Debugging webOS applications
Page 11: Debugging webOS applications

Host Mode for WebKit Inspector

• Web server running inside Palm Emulator

• Set up a tunnel from host port 5581• ssh -p 5522 -L 5581:localhost:8080 root@localhost• See hints for Windows tunnel on developer.palm.com

• Use Safari (or Chrome) to inspect your app• http://localhost:5581/Apps• http://localhost:5581/PalmApps• Enable “Develop Menu” in Safari: Prefs: Advanced• Right-click and select “Inspect Element”

Page 12: Debugging webOS applications
Page 13: Debugging webOS applications

Command Line Debugging

• novaterm or ssh to device• Type “debug” to run JavaScript debugger (like gdb)

• Hit “enter” to stop/re-start

• Common commands:• “help” and “scripts filename.js”• “break /path/to/file.js:<lineno>”, “en exc all” (catch exceptions)• “info break” and “clear <#>”• “c” (continue), “fin” (step out), “next” (step over), “step” (into)• “bt”, “down”, “up”, “frame <#>”, “scope”• “list, “list -” or “list 5,10”• “info args” or “info locals”• “print <expr>” or “set <var> = <expr>”

Page 14: Debugging webOS applications

Command Line Debugging

• Demo• $ palm-package DebugTest

• $ palm-install com.demo.debug_1.0.0_all.ipk

• $ palm-launch com.demo.debug

• # novaterm

• # debug

• dbg> <return>

• Debugger should display:• break in [anonymous](), [unnamed] line 1 column 1

• Undefined

Page 15: Debugging webOS applications

Command Line Debugging

• Demo (cont’d)• scripts first-assistant.js (list script path)

• b file:///media/…/first-assistant.js:25 (set brkpt)

• en exc all (enable exceptions all)

• c (continue, trigger brkpt)

• bt (backtrace)

• l (list)

• n (step over, hit exception)

• print Mojo.Controller.stageController

• set window.scene = Mojo.Controller.stageController.topScene()

• p scene

• p scene.sceneElement.querySelector('.palm-header').innerHTML

• p scene.sceneElement.querySelector('.palm-header').innerHTML=“foo”

• c (continue; observe header change)

• clear 1 (clear breakpoint; exit debugger)

Page 16: Debugging webOS applications

Ares (IDE) Debugger

• Better than command-line debugger• Source-level debugging• Integrated log viewer• Interactive console

• Don’t have to develop in Ares to debug with it• http://ares.palm.com• Import your project, run, and debug• Use svn (or hg) to avoid re-importing to update

Page 17: Debugging webOS applications

Ares (Standalone) Debugger

• Stand-alone Ares Debugger (NEW!)• Separate from IDE; no sources needed• Just attach and debug• http://ares.palm.com/AresDebug

• Stand-alone Ares Log Viewer• http://ares.palm.com/AresLog

• Ares will also be able to debug devices over USB

Page 18: Debugging webOS applications

Ares (Standalone) Debugger

• Demo

Page 19: Debugging webOS applications

Emulator Tips and Tricks

• GPS, Accelerometer, and Audio• GPS info: Search developer.palm.com for “luna-send”

• Accelerometer: F5 to shake; F6–F9 to rotate

• Sound: http://bit.ly/enableSound

• Suspend and Resume works!• Note: Novacom needs 5–10 seconds to reset

• VirtualBox GUI app• Renaming (or Deleting) VMs

• Prefs: Check for Updates, Auto Capture Keyboard

Page 20: Debugging webOS applications

Emulator Tips and Tricks

• Palm Emulator supports multiple webOS versions

• Current SDK emulator image installed here:• Mac: /Applications/Palm Emulator.app/Contents/Resources/Images

• Linux: /opt/PalmSDK/Current/share/emulator/images

• Windows: C:\Program Files\Palm\SDK\share\emulator\images

• You may store additional vmdk.zip files here:• Mac: ~/Library/Application Support/Palm/SDK/Images

• Linux: ~/.Palm/SDK/Images

• Windows: <user>/Local Settings/Application Data/Palm/SDK/Images

• Save old vmdk.zip before installing newer SDK

Page 21: Debugging webOS applications

Command-Line Tips

• Just remember “palm-help”• Shows all available SDK commands

• Every command supports --help• Even “palm-help --help”• Try “palm-help --sdk-info”

• If emulator won’t boot…• “palm-emulator --list”• “palm-emulator --reset=<vmname>”

• If all else fails…• Remove ~/Library/VirtualBox (deletes all VMs!)• “palm-emulator --debug”

Page 22: Debugging webOS applications

Helpful Resources

• http://developer.palm.com/• Online docs• Developer forums• Forum search is different from site search

• http://www.weboshelp.net/• (Third party site)

• IRC: irc.freenode.net• Firewall blocked? Try port 8000• Join #webos room

Page 23: Debugging webOS applications

&Q A

Page 24: Debugging webOS applications