SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Downloaden Sie, um offline zu lesen
Debugging Mobile Web
    Applications with
             weinre
                     for OSCON 2011
                        Patrick Mueller
         IBM Research Triangle Park, NC

                             @pmuellr

    1
© Copyright IBM Corp. 2011
blah blah blah


copy of this presentation available at:

      http://muellerware.org/papers/



underlined text in this presentation is a link to a web page


                                      2
resources

•   documentation - http://phonegap.github.com/weinre/

•   source / issue tracker - https://github.com/phonegap/weinre

•   discussion - http://groups.google.com/group/weinre

•   Chrome Developer Tools - http://code.google.com/chrome/devtools/docs/overview.html

    •   this doc gives a good overview of Real Web Inspector

                                           3
“weinre” pronunciation


•   like “winery”

•   not like “weiner” or “wiener”

•   I don’t really care



                                    4
deconstruct
           project / presention name
•   weinre === WEb INspector REmote

    •   reuses WebKit’s Web Inspector user interface

    •   works remotely - debug a web page running on a device from your
        desktop

•   mobile web applications - web pages running in a mobile browser or
    in a native mobile app using a browsing control (eg PhoneGap)

•   debug those web applications
                                     5
how does it work?
•   access a public weinre server or run your own

•   add a <script src=> into pages you want to debug; the src
    attribute points to a .js file provided by the weinre server

•   run the web application on your device

•   access the debugging user interface (a web page) from the weinre
    server from your desktop

•   debug!
                                   6
supported features
•   DOM / CSS inspector

    •   inspect / edit / delete DOM elements and CSS rules

•   localStorage / WebSQL inspector

•   event timeline

    •   add your own events to the timeline

•   console

    •   run arbitrary JavaScript code in your web page
                                          7
DOM / CSS inspector




         8
sql / localStorage inspector




             9
event timeline




      10
console




   11
not supported

•   JavaScript debugging; no breakpoints / pausing / stepping

•   most of the networking diagnostics

•   most of the resource diagnostics

•   profiling

•   audits

                                   12
why is <XYZ> not supported?

•   in some cases, the work has not been done yet

•   in other cases, not possible or very hard, usually because:

    •   weinre is written using plain old JavaScript

    •   no JavaScript APIs for breakpoints/stepping JavaScript code

    •   no JavaScript APIs for low-level resource information

                                       13
demo

     find a demo on YouTube:
http://www.youtube.com/results?search_query=weinre




                        14
terminology

•   debug target - the web page you want to debug

•   debug client - the web page showing the Web Inspector user
    interface

•   debug server - the HTTP server which services as a message
    switchboard between the debug target and debug client


                                  15
using weinre


•   Two options:

    •   use debug.phonegap.com, hosted by Nitobi (thanks!)

    •   download the server and run it yourself




                                     16
debug.phonegap.com




        17
pick a guid / unique id

•   weinre does not use any kind of security between debug clients and
    targets

•   the unique id keeps other people’s debug clients from connecting to
    your debug target

•   if you want to collaboratively debug, share your unique id with a
    colleague


                                    18
run your own server
•   download / unzip the “jar” build from
    https://github.com/phonegap/weinre/downloads

•   run “java -jar weinre.jar --boundHost -all-”

    •   requires Java

•   add the following to your web page, and reload it:
    <script src="http://[server-ip]:8081/target/target-script-min.js">
    </script>


                                     19
run your own server (continued)

•   browse to http://localhost:8080

•   the “Remote” panel should list your web application in green

•   that means it’s connected

•   start debugging!


                                      20
connected to your server




           21
hard part using your own server:
     the server’s ip address
•   aka “bound host”

•   --boundHost -all- option allows all ip address on the box to
    act as server; default is localhost

•   server’s ip address goes in the <script src=> element
    embedded in your web application

•   that ip address must be reachable from your device to your server

•   probably not 127.0.0.1 or localhost (maybe for emulator)
                                  22
what’s your server’s ip address?


•   Windows command line: ipconfig

•   Mac/Linux command line: ifconfig

•   weinre on your desktop: http://localhost:8080/client



                              23
weinre knows your bound hosts




              24
problem: your ip address changes
  solution: dynamic dns service
•   your ip address probably changes every day

    •   meaning you need to change the URL in your web pages every day

•   pro-tip: use a dynamic dns service with an update client

    •   now you can use a host name that never changes


                                    25
server command-line options

•   see: http://phonegap.github.com/weinre/Running.html

•   “--boundHost -all-” allows you to connect to the server from
    another machine (default only allows connections from same
    machine)

•   “--httpPort <number>” allows you to change the server port


                                  26
running the Mac application

•   a Mac application is also available

•   runs the server in a window which also displays the Web Inspector
    user interface

•   built using Eclipse SWT - theoretically possible to port to
    Windows / Linux


                                     27
mac app




   28
bookmarklet

•   possible to inject weinre target code into any web page with a
    bookmarket

•   instructions available on weinre’s main server page (when you run
    the server)

•   not trivial to install on iOS or Android, and requires modern version
    of Android


                                    29
collaborative debug

•   multiple debug clients can connect to a single debug target

•   must use a shared unique id

•   not well tested

•   not a design feature, just the way the web works


                                   30
future



  31
should be dim

•   WebKit now has Remote Web Inspector baked in
    http://www.webkit.org/blog/1620/webkit-remote-debugging/

•   RIM shipping Remote Web Inspector for Playbook

•   Apple? Don’t know, or if I did, I’d have to kill you, then myself.

•   Google? “I'm afraid we have no plans right now to enable this feature.”
    http://bit.ly/r1clCt (webkit-dev mailing list)

                                     32
easier / better
                PhoneGap integration
•   examples:

    •   auto-inject weinre JavaScript code into your app

    •   diagnostics for PhoneGap-provided events

    •   run weinre server IN your app


                                      33
current issues logged
• port the server to node.js, use socket.io for
  communications

 •   allows removal of the “message queue” code in Java and JavaScript

 •   allows WebSocket usage, for better latency / less overhead
     (instead of XHR)

 •   allows reuse of code between server and browser (wouldn’t be
     much though)

                                  34
current issues logged

• extension system that works
 • there is an extension mechanism in place today, based on Web
     Inspector’s extension mechanism

 •   allows adding new panels, and any other hacking

 •   hard/impossible to use; needs a re-write


                                   35
current issues logged

• provide better error handling
 • error support not great for mobile devices - “onerror” not yet
     ubiquitous

 •   can hook event handlers to provide try/catch with diagnostics for
     callbacks

 •   catching errors at initial load time is still hard

                                      36
until then

•   if you need something fixed or added:

    •   write a bug - https://github.com/phonegap/weinre/issues

    •   ask a question - https://groups.google.com/group/weinre

    •   DIY / fork it - https://github.com/phonegap


                                      37
innards



   38
target / server / communication



               39
communication

•   Web Inspector:

    •   defines JSON-able messages sent between client and target

    •   provides service framework to hook in message handlers

    •   provides hooks at start-up time to start your own infrastructure


                                     40
console.log(“hello, world”)
{
    interface: "ConsoleNotify",
    method:    "addConsoleMessage",
    args: [
        {
            message: "hello, world",
            level:   1,
            source: 3,
            type:    0,
            parameters: [
                {
                    hasChildren: false,
                    description: "hello, world",
                    type:        "string"
                }
            ],
        },
    ],
}
                           41
message interface / methods

•   specified in WebKit via:

    •   old: WebIDL-ish files (weinre currently using this version),
        converted to JSON in weinre build

    •   new: JSON files

•   data sent in messages not defined - “read the source”


                                      42
to implement weinre ...

•   target must respond to client’s messages correctly

•   target must send events correctly

•   basically, implement the target code - for Real Web Inspector, this is
    mainly C++, with some in JavaScript (we reuse their JavaScript)

•   set up message queue and dispatch interface in target and client


                                    43
HTTP usage
•   client and target use the same JavaScript framework for message
    sending / receiving

•   message queue-ish, REST-ish, implemented with XHR (not
    WebSocket)

•   requires Cross-Origin Resource Sharing (CORS) to let target
    communicate, cross-origin, to weinre server

•   target and client do not communicate directly, always through
    server
                                   44
HTTP / XHR message flow
         GET messages            GET messages

target                  server                  client

         POST message            POST message




                            45
source



  46
reused components

•   Apache CLI - command line parser used by the server

•   Eclipse Jetty - HTTP server used by the server (it’s not a .war)

•   Apache Wink JSON4J - JSON code for Java from used by server

•   WebKit’s Web Inspector - user interface used by the client


                                    47
Web Inspector reuse
JavaScript:        116 files 48,000 lines              1.7 MB
CSS:                 9 files 6,200 lines               140 KB
HTML:                 1 file    175 lines               1.2 KB

• Almost all of this is for the “client” - the debugger user interface
• WebKit-specific, won’t run on FireFox, IE, Opera, etc

                                    48
JavaScript modules

•   almost all JavaScript:

    •   written as CommonJS modules, using modjewel

    •   written as in classical OO style using scooj preprocessor

    •   looking at automagically porting from scooj to CoffeeScript using
        js2coffee


                                      49
build script

•   monster Ant script

    •   downloads pre-reqs (if not already downloaded)

    •   compile Java (optional, can also use Eclipse to do that)

    •   bundle all the junk together

•   if we port the server to node.js, will convert to a Makefile

                                       50

Weitere ähnliche Inhalte

Was ist angesagt?

Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Ryan Cuprak
 
Monitoring Akka with Kamon 1.0
Monitoring Akka with Kamon 1.0Monitoring Akka with Kamon 1.0
Monitoring Akka with Kamon 1.0Steffen Gebert
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by ExampleHsi-Kai Wang
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software EngineerSean Coates
 
Features, Exportables & You
Features, Exportables & YouFeatures, Exportables & You
Features, Exportables & Youjskulski
 
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems IntegrationJenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems IntegrationOleg Nenashev
 
2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudsonShreeniwas Iyer
 
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...Paul Withers
 
Log management (elk) for spring boot application
Log management (elk) for spring boot applicationLog management (elk) for spring boot application
Log management (elk) for spring boot applicationVadym Lotar
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 OverviewMike Ensor
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsSteve Keener
 
Php Dependency Management with Composer ZendCon 2017
Php Dependency Management with Composer ZendCon 2017Php Dependency Management with Composer ZendCon 2017
Php Dependency Management with Composer ZendCon 2017Clark Everetts
 
Jenkins Pipeline 101 and TCI - presentation and workshop
Jenkins Pipeline 101 and TCI - presentation and workshopJenkins Pipeline 101 and TCI - presentation and workshop
Jenkins Pipeline 101 and TCI - presentation and workshopYoram Michaeli
 
Docker - From Walking To Running
Docker - From Walking To RunningDocker - From Walking To Running
Docker - From Walking To RunningGiacomo Vacca
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...Jesse Gallagher
 

Was ist angesagt? (20)

Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and Hybrid Mobile Development with Apache Cordova and
Hybrid Mobile Development with Apache Cordova and
 
Monitoring Akka with Kamon 1.0
Monitoring Akka with Kamon 1.0Monitoring Akka with Kamon 1.0
Monitoring Akka with Kamon 1.0
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer30 Skills to Master to Become a Senior Software Engineer
30 Skills to Master to Become a Senior Software Engineer
 
Features, Exportables & You
Features, Exportables & YouFeatures, Exportables & You
Features, Exportables & You
 
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems IntegrationJenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
 
Pantheon basics
Pantheon basicsPantheon basics
Pantheon basics
 
Maven
MavenMaven
Maven
 
2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson
 
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
IBM ConnectED 2015 - BP106 From XPages Hero To OSGi Guru: Taking The Scary Ou...
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Log management (elk) for spring boot application
Log management (elk) for spring boot applicationLog management (elk) for spring boot application
Log management (elk) for spring boot application
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
 
Maven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable ResultsMaven: Managing Software Projects for Repeatable Results
Maven: Managing Software Projects for Repeatable Results
 
Php Dependency Management with Composer ZendCon 2017
Php Dependency Management with Composer ZendCon 2017Php Dependency Management with Composer ZendCon 2017
Php Dependency Management with Composer ZendCon 2017
 
Jenkins Pipeline 101 and TCI - presentation and workshop
Jenkins Pipeline 101 and TCI - presentation and workshopJenkins Pipeline 101 and TCI - presentation and workshop
Jenkins Pipeline 101 and TCI - presentation and workshop
 
Docker - From Walking To Running
Docker - From Walking To RunningDocker - From Walking To Running
Docker - From Walking To Running
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
 

Andere mochten auch

Thuat ngu thong ke nam 2011
Thuat ngu thong ke nam 2011Thuat ngu thong ke nam 2011
Thuat ngu thong ke nam 2011huongquynh
 
Hottest penny stocks - part 1
Hottest penny stocks  - part 1Hottest penny stocks  - part 1
Hottest penny stocks - part 1Practice of Law
 
Sakichitoyodatoyota thay doi_cong_thuc_cua_khat_vong_2824
Sakichitoyodatoyota thay doi_cong_thuc_cua_khat_vong_2824Sakichitoyodatoyota thay doi_cong_thuc_cua_khat_vong_2824
Sakichitoyodatoyota thay doi_cong_thuc_cua_khat_vong_2824huongquynh
 
Stock trading tips - view stocks like a market maker
Stock trading tips  - view stocks like a market makerStock trading tips  - view stocks like a market maker
Stock trading tips - view stocks like a market makerPractice of Law
 
SEC Regulation D, Rule 506 C, Advertising Your Private Securities Offering
SEC Regulation D, Rule 506 C, Advertising Your Private Securities OfferingSEC Regulation D, Rule 506 C, Advertising Your Private Securities Offering
SEC Regulation D, Rule 506 C, Advertising Your Private Securities OfferingPractice of Law
 
Good penny stocks for 2011 2
Good penny stocks for 2011   2Good penny stocks for 2011   2
Good penny stocks for 2011 2Practice of Law
 
Venture funding - real purpose of corporate finance
Venture funding  - real purpose of corporate financeVenture funding  - real purpose of corporate finance
Venture funding - real purpose of corporate financePractice of Law
 

Andere mochten auch (8)

Thuat ngu thong ke nam 2011
Thuat ngu thong ke nam 2011Thuat ngu thong ke nam 2011
Thuat ngu thong ke nam 2011
 
Hottest penny stocks - part 1
Hottest penny stocks  - part 1Hottest penny stocks  - part 1
Hottest penny stocks - part 1
 
Sakichitoyodatoyota thay doi_cong_thuc_cua_khat_vong_2824
Sakichitoyodatoyota thay doi_cong_thuc_cua_khat_vong_2824Sakichitoyodatoyota thay doi_cong_thuc_cua_khat_vong_2824
Sakichitoyodatoyota thay doi_cong_thuc_cua_khat_vong_2824
 
Stock trading tips - view stocks like a market maker
Stock trading tips  - view stocks like a market makerStock trading tips  - view stocks like a market maker
Stock trading tips - view stocks like a market maker
 
Buy cheap stocks
Buy cheap stocksBuy cheap stocks
Buy cheap stocks
 
SEC Regulation D, Rule 506 C, Advertising Your Private Securities Offering
SEC Regulation D, Rule 506 C, Advertising Your Private Securities OfferingSEC Regulation D, Rule 506 C, Advertising Your Private Securities Offering
SEC Regulation D, Rule 506 C, Advertising Your Private Securities Offering
 
Good penny stocks for 2011 2
Good penny stocks for 2011   2Good penny stocks for 2011   2
Good penny stocks for 2011 2
 
Venture funding - real purpose of corporate finance
Venture funding  - real purpose of corporate financeVenture funding  - real purpose of corporate finance
Venture funding - real purpose of corporate finance
 

Ähnlich wie Oscon 2011-mueller-weinre

Web dev tools review
Web dev tools reviewWeb dev tools review
Web dev tools reviewChanghyun Lee
 
The Hacking Games - A Road to Post Exploitation Meetup - 20240222.pptx
The Hacking Games - A Road to Post Exploitation Meetup - 20240222.pptxThe Hacking Games - A Road to Post Exploitation Meetup - 20240222.pptx
The Hacking Games - A Road to Post Exploitation Meetup - 20240222.pptxlior mazor
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefNathen Harvey
 
Open Audit
Open AuditOpen Audit
Open Auditncspa
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a proMarko Heijnen
 
Developing Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDeveloping Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDoris Chen
 
JCON_15FactorWorkshop.pptx
JCON_15FactorWorkshop.pptxJCON_15FactorWorkshop.pptx
JCON_15FactorWorkshop.pptxGrace Jansen
 
Introduction to SignalR
Introduction to SignalRIntroduction to SignalR
Introduction to SignalRAdam Mokan
 
321 codeincontainer brewbox
321 codeincontainer brewbox321 codeincontainer brewbox
321 codeincontainer brewboxLino Telera
 
Rock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsRock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsPablo Godel
 
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...Daniel Bryant
 
Progressive Enhancement using WSGI
Progressive Enhancement using WSGIProgressive Enhancement using WSGI
Progressive Enhancement using WSGIMatthew Wilkes
 
Service workers your applications never felt so good
Service workers   your applications never felt so goodService workers   your applications never felt so good
Service workers your applications never felt so goodChris Love
 
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Zach Lendon
 
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementMidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementZach Lendon
 

Ähnlich wie Oscon 2011-mueller-weinre (20)

Web dev tools review
Web dev tools reviewWeb dev tools review
Web dev tools review
 
20120306 dublin js
20120306 dublin js20120306 dublin js
20120306 dublin js
 
The Hacking Games - A Road to Post Exploitation Meetup - 20240222.pptx
The Hacking Games - A Road to Post Exploitation Meetup - 20240222.pptxThe Hacking Games - A Road to Post Exploitation Meetup - 20240222.pptx
The Hacking Games - A Road to Post Exploitation Meetup - 20240222.pptx
 
Introduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to ChefIntroduction to Infrastructure as Code & Automation / Introduction to Chef
Introduction to Infrastructure as Code & Automation / Introduction to Chef
 
Open Audit
Open AuditOpen Audit
Open Audit
 
Transforming the web into a real application platform
Transforming the web into a real application platformTransforming the web into a real application platform
Transforming the web into a real application platform
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a pro
 
Developing Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax PushDeveloping Revolutionary Web Applications using Comet and Ajax Push
Developing Revolutionary Web Applications using Comet and Ajax Push
 
Vagrant to-aws-flow
Vagrant to-aws-flowVagrant to-aws-flow
Vagrant to-aws-flow
 
JCON_15FactorWorkshop.pptx
JCON_15FactorWorkshop.pptxJCON_15FactorWorkshop.pptx
JCON_15FactorWorkshop.pptx
 
Introduction to SignalR
Introduction to SignalRIntroduction to SignalR
Introduction to SignalR
 
Introduction to SignalR
Introduction to SignalRIntroduction to SignalR
Introduction to SignalR
 
321 codeincontainer brewbox
321 codeincontainer brewbox321 codeincontainer brewbox
321 codeincontainer brewbox
 
Rock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsRock Solid Deployment of Web Applications
Rock Solid Deployment of Web Applications
 
Mini-Training Owin Katana
Mini-Training Owin KatanaMini-Training Owin Katana
Mini-Training Owin Katana
 
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
Devoxx UK 22: Debugging Java Microservices "Remocally" in Kubernetes with Tel...
 
Progressive Enhancement using WSGI
Progressive Enhancement using WSGIProgressive Enhancement using WSGI
Progressive Enhancement using WSGI
 
Service workers your applications never felt so good
Service workers   your applications never felt so goodService workers   your applications never felt so good
Service workers your applications never felt so good
 
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
Reconciling ReactJS as a View Layer Replacement (MidwestJS 2014)
 
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer ReplacementMidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
MidwestJS 2014 Reconciling ReactJS as a View Layer Replacement
 

Kürzlich hochgeladen

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Kürzlich hochgeladen (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

Oscon 2011-mueller-weinre

  • 1. Debugging Mobile Web Applications with weinre for OSCON 2011 Patrick Mueller IBM Research Triangle Park, NC @pmuellr 1
  • 2. © Copyright IBM Corp. 2011 blah blah blah copy of this presentation available at: http://muellerware.org/papers/ underlined text in this presentation is a link to a web page 2
  • 3. resources • documentation - http://phonegap.github.com/weinre/ • source / issue tracker - https://github.com/phonegap/weinre • discussion - http://groups.google.com/group/weinre • Chrome Developer Tools - http://code.google.com/chrome/devtools/docs/overview.html • this doc gives a good overview of Real Web Inspector 3
  • 4. “weinre” pronunciation • like “winery” • not like “weiner” or “wiener” • I don’t really care 4
  • 5. deconstruct project / presention name • weinre === WEb INspector REmote • reuses WebKit’s Web Inspector user interface • works remotely - debug a web page running on a device from your desktop • mobile web applications - web pages running in a mobile browser or in a native mobile app using a browsing control (eg PhoneGap) • debug those web applications 5
  • 6. how does it work? • access a public weinre server or run your own • add a <script src=> into pages you want to debug; the src attribute points to a .js file provided by the weinre server • run the web application on your device • access the debugging user interface (a web page) from the weinre server from your desktop • debug! 6
  • 7. supported features • DOM / CSS inspector • inspect / edit / delete DOM elements and CSS rules • localStorage / WebSQL inspector • event timeline • add your own events to the timeline • console • run arbitrary JavaScript code in your web page 7
  • 8. DOM / CSS inspector 8
  • 9. sql / localStorage inspector 9
  • 11. console 11
  • 12. not supported • JavaScript debugging; no breakpoints / pausing / stepping • most of the networking diagnostics • most of the resource diagnostics • profiling • audits 12
  • 13. why is <XYZ> not supported? • in some cases, the work has not been done yet • in other cases, not possible or very hard, usually because: • weinre is written using plain old JavaScript • no JavaScript APIs for breakpoints/stepping JavaScript code • no JavaScript APIs for low-level resource information 13
  • 14. demo find a demo on YouTube: http://www.youtube.com/results?search_query=weinre 14
  • 15. terminology • debug target - the web page you want to debug • debug client - the web page showing the Web Inspector user interface • debug server - the HTTP server which services as a message switchboard between the debug target and debug client 15
  • 16. using weinre • Two options: • use debug.phonegap.com, hosted by Nitobi (thanks!) • download the server and run it yourself 16
  • 18. pick a guid / unique id • weinre does not use any kind of security between debug clients and targets • the unique id keeps other people’s debug clients from connecting to your debug target • if you want to collaboratively debug, share your unique id with a colleague 18
  • 19. run your own server • download / unzip the “jar” build from https://github.com/phonegap/weinre/downloads • run “java -jar weinre.jar --boundHost -all-” • requires Java • add the following to your web page, and reload it: <script src="http://[server-ip]:8081/target/target-script-min.js"> </script> 19
  • 20. run your own server (continued) • browse to http://localhost:8080 • the “Remote” panel should list your web application in green • that means it’s connected • start debugging! 20
  • 21. connected to your server 21
  • 22. hard part using your own server: the server’s ip address • aka “bound host” • --boundHost -all- option allows all ip address on the box to act as server; default is localhost • server’s ip address goes in the <script src=> element embedded in your web application • that ip address must be reachable from your device to your server • probably not 127.0.0.1 or localhost (maybe for emulator) 22
  • 23. what’s your server’s ip address? • Windows command line: ipconfig • Mac/Linux command line: ifconfig • weinre on your desktop: http://localhost:8080/client 23
  • 24. weinre knows your bound hosts 24
  • 25. problem: your ip address changes solution: dynamic dns service • your ip address probably changes every day • meaning you need to change the URL in your web pages every day • pro-tip: use a dynamic dns service with an update client • now you can use a host name that never changes 25
  • 26. server command-line options • see: http://phonegap.github.com/weinre/Running.html • “--boundHost -all-” allows you to connect to the server from another machine (default only allows connections from same machine) • “--httpPort <number>” allows you to change the server port 26
  • 27. running the Mac application • a Mac application is also available • runs the server in a window which also displays the Web Inspector user interface • built using Eclipse SWT - theoretically possible to port to Windows / Linux 27
  • 28. mac app 28
  • 29. bookmarklet • possible to inject weinre target code into any web page with a bookmarket • instructions available on weinre’s main server page (when you run the server) • not trivial to install on iOS or Android, and requires modern version of Android 29
  • 30. collaborative debug • multiple debug clients can connect to a single debug target • must use a shared unique id • not well tested • not a design feature, just the way the web works 30
  • 32. should be dim • WebKit now has Remote Web Inspector baked in http://www.webkit.org/blog/1620/webkit-remote-debugging/ • RIM shipping Remote Web Inspector for Playbook • Apple? Don’t know, or if I did, I’d have to kill you, then myself. • Google? “I'm afraid we have no plans right now to enable this feature.” http://bit.ly/r1clCt (webkit-dev mailing list) 32
  • 33. easier / better PhoneGap integration • examples: • auto-inject weinre JavaScript code into your app • diagnostics for PhoneGap-provided events • run weinre server IN your app 33
  • 34. current issues logged • port the server to node.js, use socket.io for communications • allows removal of the “message queue” code in Java and JavaScript • allows WebSocket usage, for better latency / less overhead (instead of XHR) • allows reuse of code between server and browser (wouldn’t be much though) 34
  • 35. current issues logged • extension system that works • there is an extension mechanism in place today, based on Web Inspector’s extension mechanism • allows adding new panels, and any other hacking • hard/impossible to use; needs a re-write 35
  • 36. current issues logged • provide better error handling • error support not great for mobile devices - “onerror” not yet ubiquitous • can hook event handlers to provide try/catch with diagnostics for callbacks • catching errors at initial load time is still hard 36
  • 37. until then • if you need something fixed or added: • write a bug - https://github.com/phonegap/weinre/issues • ask a question - https://groups.google.com/group/weinre • DIY / fork it - https://github.com/phonegap 37
  • 38. innards 38
  • 39. target / server / communication 39
  • 40. communication • Web Inspector: • defines JSON-able messages sent between client and target • provides service framework to hook in message handlers • provides hooks at start-up time to start your own infrastructure 40
  • 41. console.log(“hello, world”) { interface: "ConsoleNotify", method: "addConsoleMessage", args: [ { message: "hello, world", level: 1, source: 3, type: 0, parameters: [ { hasChildren: false, description: "hello, world", type: "string" } ], }, ], } 41
  • 42. message interface / methods • specified in WebKit via: • old: WebIDL-ish files (weinre currently using this version), converted to JSON in weinre build • new: JSON files • data sent in messages not defined - “read the source” 42
  • 43. to implement weinre ... • target must respond to client’s messages correctly • target must send events correctly • basically, implement the target code - for Real Web Inspector, this is mainly C++, with some in JavaScript (we reuse their JavaScript) • set up message queue and dispatch interface in target and client 43
  • 44. HTTP usage • client and target use the same JavaScript framework for message sending / receiving • message queue-ish, REST-ish, implemented with XHR (not WebSocket) • requires Cross-Origin Resource Sharing (CORS) to let target communicate, cross-origin, to weinre server • target and client do not communicate directly, always through server 44
  • 45. HTTP / XHR message flow GET messages GET messages target server client POST message POST message 45
  • 47. reused components • Apache CLI - command line parser used by the server • Eclipse Jetty - HTTP server used by the server (it’s not a .war) • Apache Wink JSON4J - JSON code for Java from used by server • WebKit’s Web Inspector - user interface used by the client 47
  • 48. Web Inspector reuse JavaScript: 116 files 48,000 lines 1.7 MB CSS: 9 files 6,200 lines 140 KB HTML: 1 file 175 lines 1.2 KB • Almost all of this is for the “client” - the debugger user interface • WebKit-specific, won’t run on FireFox, IE, Opera, etc 48
  • 49. JavaScript modules • almost all JavaScript: • written as CommonJS modules, using modjewel • written as in classical OO style using scooj preprocessor • looking at automagically porting from scooj to CoffeeScript using js2coffee 49
  • 50. build script • monster Ant script • downloads pre-reqs (if not already downloaded) • compile Java (optional, can also use Eclipse to do that) • bundle all the junk together • if we port the server to node.js, will convert to a Makefile 50