Debugging webOS applications

8,297 views

Published on

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

Published in: Technology
1 Comment
5 Likes
Statistics
Notes
  • you can use DebugGap to debug, it's powerful. it can debug phonegap and browsers
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
8,297
On SlideShare
0
From Embeds
0
Number of Embeds
70
Actions
Shares
0
Downloads
399
Comments
1
Likes
5
Embeds 0
No embeds

No notes for slide

Debugging webOS applications

  1. 1. Debugging webOS Applications Steve Lemke webOS Tools Engineering April 23, 2010
  2. 2. 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)
  3. 3. 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
  4. 4. 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)
  5. 5. 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
  6. 6. 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
  7. 7. Palm Inspector • Launch application with “palm-launch -i <appname>” • Launch “Palm Inspector” app • Type “palm-inspector” on Linux • Emulator only
  8. 8. Palm WORM • Launch “palm-worm” app • Live graphs of: • Total DOM nodes • Open service handles • JavaScript heap usage • Emulator only
  9. 9. 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”
  10. 10. 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>”
  11. 11. 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
  12. 12. 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)
  13. 13. 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
  14. 14. 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
  15. 15. Ares (Standalone) Debugger • Demo
  16. 16. 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
  17. 17. 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 FilesPalmSDKshareemulatorimages • 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
  18. 18. 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”
  19. 19. 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
  20. 20. Q &A

×