Giter Club home page Giter Club logo

polydev's Introduction

polydev

polydev is the Polymer DevTools Extension - a tool to help develop Polymer and custom elements. Currently it's focused on performance tracking of web components.

How to Use

  1. Install the extension.
  2. On a page that uses web components, make a timeline recording.
  3. Look under the User Timing section of the timeline to track time spent in custom element lifecycle callbacks, as well as time spent reacting to Polymer databinding changes.

How to read the results

Screenshot of a recorded timeline

Each web component lifecycle callback will be annotated as a span in the timeline called a measure, representing the time that it took. If a measure is below another measure, the lower callback took place during the higher callback.

Each measure that polydev produces has a unique name like [WC] created paper-icon-button 5. The format is [WC] callbackName tagName id. The id numbers are on a per instance and per tag basis and count up from zero.

API

polydev exposes a method on the host page called _getElementMeasures. It returns an array of ElementMeasure objects, which obey the following interface:

interface ElementMeasurement {
  tagName: string;
  operation: string;
  elementId: number|undefined;
  duration: number;
  start: number;
  end: number;
}

Development

Building

polydev must be built before running. The build step externalizes inline scripts for CSP compliance, and copies some dependencies into convenient locations.

To build, run npm run build:

> npm run build

The built project is available at build/polydev.

Installation

  1. Create a new Chrome profile
  2. Navigate to chrome://extensions
  3. Check the "Developer mode" checkbox
  4. Click "Load unpacked extension..."
  5. Choose polydev/build/polydev

Dev flow

When changing files in src/ the dev workflow should work cover most use cases.

> npm run dev

Depending on the change you can either then close and reopen the devtools, or if you've made a change to the content-script or to element-zones, you must reload both the extension and any page you're testing it on.

polydev's People

Contributors

justinfagnani avatar paulirish avatar rictic avatar samccone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

polydev's Issues

Chromium support?

Chromium 44.0.2403.89, Linux
Poolymer tab is present, but completely empty (tried browser restart, page reload, etc.)

google search broken

When polydev is enabled, google search is broken. It still works when entering a query in the address bar, but when changing the query in the search field of the page and pressing enter, the search results become and remain disabled.
The following error message is shown in the console:

polydev/vendor/zone-microtask.js:123 Uncaught TypeError: Cannot read property 'elements' of undefined

polymer summit

Who is showing this at polymer summit!? I will probably use it myself.. :)

Only inject zone.js if we are looking at a polymer app / inspecting ๐Ÿ”

Or something like this... zone.js breaks quite a few sites ATM (like google)
Would be nice if this plugin did not break other sites ๐Ÿ˜‰

I like the approach we used here https://github.com/marionettejs/marionette.inspector
where you have to manually opt in to running the script

we then kinda hack into the guts of backbone and marionette and reload the page

cc @jasonLaster prob will have more insight on this for us ๐Ÿ‘

polydev causing paper-dialog to fail.

Uncaught TypeError: Cannot read property 'toString' of null

below is the code giving the issue:
handler is null.

function patchEventTargetMethods(obj) {
var addDelegate = obj.addEventListener;
obj.addEventListener = function (eventName, handler) {
var fn;
//Ignore special listeners of IE11 & Edge dev tools, see angular/zone.js#150
if (handler.toString() !== "[object FunctionWrapper]") {

CSS Custom Property Inspector

Users should be able to see what custom properties have cascaded to an element.

This will be useful even when Chrome lands native custom property support to debug issues when using the polyfill in other browsers.

bower dependencies seem broken

Are we supposed to get element-zones via bower? I'm having trouble finding the right version. When I manually remove the branch name (just PolymerLabs/element-zones in bower.json) I get more 404s for things like imd#export (which is also dependend on from element-zones).

~/dev/polymer/polydev % bower install
bower element-zones#^0.2.0  not-cached git://github.com/PolymerLabs/element-zones.git#^0.2.0
bower element-zones#^0.2.0     resolve git://github.com/PolymerLabs/element-zones.git#^0.2.0
bower imd#export            not-cached git://github.com/PolymerLabs/imd.git#export
bower imd#export               resolve git://github.com/PolymerLabs/imd.git#export
bower polymer#~1.1.1            cached git://github.com/Polymer/polymer.git#1.1.5
bower polymer#~1.1.1          validate 1.1.5 against git://github.com/Polymer/polymer.git#~1.1.1
bower iron-icons#~1.0.3         cached git://github.com/PolymerElements/iron-icons.git#1.0.6
bower iron-icons#~1.0.3       validate 1.0.6 against git://github.com/PolymerElements/iron-icons.git#~1.0.3
bower paper-button#~1.0.4       cached git://github.com/PolymerElements/paper-button.git#1.0.11
bower paper-button#~1.0.4     validate 1.0.11 against git://github.com/PolymerElements/paper-button.git#~1.0.4
bower paper-material#~1.0.2     cached git://github.com/PolymerElements/paper-material.git#1.0.6
bower paper-material#~1.0.2   validate 1.0.6 against git://github.com/PolymerElements/paper-material.git#~1.0.2
bower iron-icon#~1.0.4          cached git://github.com/PolymerElements/iron-icon.git#1.0.8
bower iron-icon#~1.0.4        validate 1.0.8 against git://github.com/PolymerElements/iron-icon.git#~1.0.4
bower polymer#^1.0.0            cached git://github.com/Polymer/polymer.git#1.4.0
bower polymer#^1.0.0          validate 1.4.0 against git://github.com/Polymer/polymer.git#^1.0.0
bower iron-iconset-svg#^1.0.0   cached git://github.com/polymerelements/iron-iconset-svg.git#1.0.9
bower iron-iconset-svg#^1.0.0 validate 1.0.9 against git://github.com/polymerelements/iron-iconset-svg.git#^1.0.0
bower paper-material#^1.0.0     cached git://github.com/polymerelements/paper-material.git#1.0.6
bower paper-material#^1.0.0   validate 1.0.6 against git://github.com/polymerelements/paper-material.git#^1.0.0
bower paper-ripple#^1.0.0       cached git://github.com/polymerelements/paper-ripple.git#1.0.5
bower paper-ripple#^1.0.0     validate 1.0.5 against git://github.com/polymerelements/paper-ripple.git#^1.0.0
bower iron-icon#^1.0.0          cached git://github.com/polymerelements/iron-icon.git#1.0.8
bower iron-icon#^1.0.0        validate 1.0.8 against git://github.com/polymerelements/iron-icon.git#^1.0.0
bower paper-behaviors#^1.0.0    cached git://github.com/polymerelements/paper-behaviors.git#1.0.11
bower paper-behaviors#^1.0.0  validate 1.0.11 against git://github.com/polymerelements/paper-behaviors.git#^1.0.0
bower iron-flex-layout#^1.0.0   cached git://github.com/polymerelements/iron-flex-layout.git#1.3.1
bower iron-flex-layout#^1.0.0 validate 1.3.1 against git://github.com/polymerelements/iron-flex-layout.git#^1.0.0
bower element-zones#^0.2.0     ENORESTARGET No tag found that was able to satisfy ^0.2.0

breaks Google Play Music

When I have this extension enabled, the search bar at the top of the page refuses to actually perform searches (although accepts search terms, etc), and the spinning activity indicator is perpetually visible (even when nothing should be happening).

Uninstalling / disabling this extension restores expected behaviour in Google Play Music.

Shady DOM: light and local DOM tree panes

With Shady DOM the element panel shows only the composed tree. It may be useful for the developer to see both the light and local tree from Shady DOM, and to be able to select those elements as in the built-in elements panel.

There may be limitations, like not being able to see styles for non-distributed nodes.

Time visualization style

i.e

screen shot 2015-09-09 at 11 08 12 pm

I think this will make it a bunch easier for humans to understand the numbers


I defer to @paulirish for some sage knowledge on the best way to present this one ๐Ÿ™‡

polydev causes more issues in paper-dropdown

Open the below link in chrome with polydev enabled

http://output.jsbin.com/curike

  1. When I open the dropdown, I see a message "Uncaught TypeError: Cannot read property 'toString' of null polydev/vendor/zone-microtask.js:973".
  2. When I try to close the dropdown by clicking outside, it does not close.
  3. When I select a value, I get another message "Uncaught TypeError: Cannot read property '_bound' of null polydev/vendor/zone-microtask.js:995"

The issues disappear when I disabled polydev.

Iron Overlay type error on open in Chrome

From @fozziethebeat on October 29, 2015 18:28

I've recently seen a problem in Chrome on both Ubuntu and Mac OSX where opening an iron-overlay throws a Javascript error:

Uncaught TypeError: Cannot read property 'toString' of null

The full stack trace looks like:

obj.addEventListener    @   polydev/vendor/zone-microtask.js:973
Gestures.add    @   polymer.html:752 
Polymer.IronOverlayBehaviorImpl._toggleListener @   iron-overlay-behavior.html:268
(anonymous function)    @   iron-overlay-behavior.html:286
arguments.(anonymous function)  @   polydev/vendor/zone-microtask.js:406
(anonymous function)    @   polydev/vendor/zone-microtask.js:98
run @   polydev/vendor/zone-microtask.js:118
zoneBoundFn @   polydev/vendor/zone-microtask.js:91

I've seen this with both iron-dropdown and several custom elements I've used that mixin iron-overlay-behavior.

Copied from original issue: PolymerElements/iron-overlay-behavior#47

Property inspector pane

Users should be able to see and edit properties of Polymer elements selected in the elements panel.

Uncaught TypeError: Cannot read property 'toString' of null on paper-dialog

I got next error on dialog opening:

obj.addEventListener    @   polydev/vendor/zone-microtask.js:973
Gestures.add    @   polymer.html:774
Polymer.IronOverlayBehaviorImpl._toggleListener @   iron-overlay-behavior.html:268
(anonymous function)    @   iron-overlay-behavior.html:286
(anonymous function)    @   polymer.html:1355
arguments.(anonymous function)  @   polydev/vendor/zone-microtask.js:406
(anonymous function)    @   polydev/vendor/zone-microtask.js:98
run @   polydev/vendor/zone-microtask.js:118
zoneBoundFn @   polydev/vendor/zone-microtask.js:91

I was told that it's an issue related to polydev (not to polymer itself), so please take a look to it.

Polydev breaks Polymer website (and other websites)

Description:

The Polydev plugin is causing some serious issues that prevent browsing relevant Polymer Project documentation or other websites with the script enabled. I know its recommended to install the plugin on a different profile in Chrome, but it seems inconvenient that the plugin specifically breaks the https://www.polymer-project.org/1.0/ website and the documentation hosted on it.

Issue:

When I visit https://www.polymer-project.org/1.0/ website with the Polydev Chrome plugin installed, the plugin prevents scripts on the page from running successfully and prevents the page UI from being drawn correctly (the header and logos no longer resize and display correctly).

When I've left the plugin running in the background, I've noticed it causes similar TypeErrors Cannot read property '_bound' of null on other websites and breaks functionality.

Screenshot of Polymer Project website with plugin installed:

image

Relevant error log from the Chrome console:

Uncaught TypeError: Cannot read property '_bound' of null
    at HTMLDocument.obj.removeEventListener (polydev/vendor/zone-microtask.js:995:15)
    at HTMLElement._resetFocusedContent (https://www.polymer-project.org/elements/elements.js:18:20083)
    at HTMLElement._complexObserverEffect (https://www.polymer-project.org/elements/elements.js:13:12758)
    at HTMLElement._effectEffects (https://www.polymer-project.org/elements/elements.js:13:10019)
    at HTMLElement._propertySetter (https://www.polymer-project.org/elements/elements.js:13:9767)
    at HTMLElement.__setProperty (https://www.polymer-project.org/elements/elements.js:13:9891)
    at HTMLElement._applyConfig (https://www.polymer-project.org/elements/elements.js:13:20952)
    at HTMLElement._afterClientsReady (https://www.polymer-project.org/elements/elements.js:13:20819)
    at HTMLElement._ready (https://www.polymer-project.org/elements/elements.js:11:16053)
    at HTMLElement._readyClients (https://www.polymer-project.org/elements/elements.js:11:16212)

Environment:

OS: OSX 10.11.6
Chrome build: 54.0.2840.87
Polydev build: 0.0.6

Thanks!

Thanks for providing this plugin. Let me know if I can provide you with any additional information to help you resolve the problem.

Suggestion: Debug view for binding system

I don't know if this is something polydev could be the right place for, but I wanted to propose this anyway.

If one builds an application with the mediator pattern and therefore makes heavy use of the data binding system, I think it would be quite useful if we had the ability to record the data flow in the binding system.

Would love to here what you guys think?

Breaks commenting on GitHub

When this extension is enabled in Chrome, all of the GitHub key mappings on a pull request page to open sidebar selection dialogs (i.e, 'a' opens Assignees, 'l' opens Labels, [P]rojects, and [M]ilestones) will fire even typing in an input field. It seems to break the default event propagation behavior for input fields.

Doesn't work on chrome:// WebUI

On chrome://settings and other WebUI which use Polymer elements, the Polymer tab only displays a "Custom Element Profile" card with a "REFRESH" button; clicking the Refresh button does nothing.

From the extension:

polymer-panel connected Port {sender: Object}
background.js:23 from polymer-panel Object {messageType: "tab-id", tabId: 23} Port {sender: Object}
background.js:25 polymer-page tab-id 23
background.js:23 from polymer-panel Object {messageType: "get-element-stats", tabId: 23} Port {sender: Object}
extensions::uncaught_exception_handler:8 Error in event handler for (unknown): TypeError: Cannot read property 'postMessage' of undefined
    at chrome-extension://mmpfaamodhhlbadloaibpocmcomledcg/src/background.js:37:13handler @ extensions::uncaught_exception_handler:8exports.handle @ extensions::uncaught_exception_handler:100EventImpl.dispatch_ @ extensions::event_bindings:376EventImpl.dispatch @ extensions::event_bindings:393target.(anonymous function) @ extensions::SafeBuiltins:19publicClass.(anonymous function) @ extensions::utils:94dispatchOnMessage @ extensions::messaging:310
background.js:44 element-zones.onConnect Port {sender: Object} 25

Add MOAR metrics!

The perf bookmarklet at https://gist.github.com/ebidel/57c9e9379ec6b0bda16d has some numbers that would be interesting to add:

  • first paint
  • page load
  • resource timing api load times for the page's top level html imports.
  • instance count
  • properties that are set to reflectToAttribute and the element that the property belongs to (can be a source of bad perf)
  • WebComponentsReady firing time
  • HTMLImportsLoaded firing time

Polymer.dart Support

It would be wonderful if the developer tools supported Polymer.dart as well as Polymer.js; either natively in Dartium, or, more likely, though dart2js compiled code in Chrome.

Currently when attempting to use the extension on a Polymer.dart (transpiled to JS) site, I get a stack trace in the Console, and the page fails to load at all:

Uncaught TypeError: Cannot assign to read only property 'createdCallback' of #<HTMLElement>
    document.registerElement @ VM793:2128
    registerElement @ interop_support.js:64
    dart._registerCustomElement @ html_dart2js.dart:40049
    dart.PolymerDeclaration.registerType$1 @ html_dart2js.dart:18101
    dart._hookJsPolymer_registerDart_closure.call$0 @ declaration.dart:128
    dart._RootZone.run$1 @ zone.dart:1161
    dart._hookJsPolymer_registerDart.call$3 @ loader.dart:86
    dart.Primitives_applyFunctionWithPositionalArguments @ js_helper.dart:1386
    dart._callDartFunction @ js_helper.dart:1347
    (anonymous function) @ js_dart2js.dart:103
    d._register @ polymer.min.js:14
    f.flush @ polymer.min.js:14
    f.ready @ polymer.min.js:14
    f.check @ polymer.min.js:14
    (anonymous function) @ polymer.min.js:14
    n @ webcomponents.min.js:14
    i @ webcomponents.min.js:14
    (anonymous function) @ webcomponents.min.js:14
    r @ webcomponents.min.js:14
    t @ webcomponents.min.js:14
    (anonymous function) @ polymer.min.js:14
    c @ polymer.min.js:13
    run @ VM793:118
    zoneBoundFn @ VM793:91

Polymer's `async` returns `undefined` if the extension is enabled.

Suddenly all return values from Polymer.Base.async were undefined. As soon as I disabled the polydev extension, the return values were all fine again.

With polydev enabled

ready: function() {
  var job = this.async(function() { console.log('did it'); }, 1000);
  console.log(job); // -> undefined
}

With polydev disabled

ready: function() {
  var job = this.async(function() { console.log('did it'); }, 1000);
  console.log(job); // -> -3   as expected
}

Is polydev maybe hungry for the return values ;)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.