Add timeline traces in the console, let enabling them through the package.json

This commit is contained in:
Panayot Cankov
2017-06-02 16:34:04 +03:00
parent 63633533bc
commit 51b351f5b6
24 changed files with 282 additions and 128 deletions

View File

@@ -6,6 +6,8 @@ import { ViewBase } from "../view-base";
import { WrappedValue, PropertyChangeData } from "../../../data/observable";
import { Style } from "../../styling/style";
import { profile } from "../../../profiling";
export { Style };
export const unsetValue: any = new Object();
@@ -964,7 +966,7 @@ function inheritableCssPropertyValuesOn(style: Style): Array<{ property: Inherit
return array;
}
export function initNativeView(view: ViewBase): void {
export const initNativeView = profile('"properties".initNativeView', function initNativeView(view: ViewBase): void {
let symbols = Object.getOwnPropertySymbols(view);
for (let symbol of symbols) {
const property: Property<any, any> = symbolPropertyMap[symbol];
@@ -1005,7 +1007,7 @@ export function initNativeView(view: ViewBase): void {
view[property.setNative](value);
}
}
}
});
export function resetNativeView(view: ViewBase): void {
let symbols = Object.getOwnPropertySymbols(view);

View File

@@ -17,6 +17,8 @@ import * as types from "../../../utils/types";
import { Color } from "../../../color";
import { profile } from "../../../profiling";
export { isIOS, isAndroid, layout, Color };
export * from "../bindable";
export * from "../properties";
@@ -260,6 +262,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
this[name] = WrappedValue.unwrap(value);
}
@profile
public onLoaded() {
this._isLoaded = true;
this._loadEachChild();
@@ -273,6 +276,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
});
}
@profile
public onUnloaded() {
this._unloadEachChild();
this._isLoaded = false;
@@ -299,6 +303,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
});
}
@profile
public _applyStyleFromScope() {
const scope = this._styleScope;
if (scope) {
@@ -309,6 +314,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
}
// TODO: Make sure the state is set to null and this is called on unloaded to clean up change listeners...
@profile
_setCssState(next: ssm.CssState): void {
const previous = this._cssState;
this._cssState = next;
@@ -380,6 +386,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
private _invalidateCssHandler;
private _invalidateCssHandlerSuspended: boolean;
@profile
private applyCssState(): void {
this._batchUpdate(() => {
if (!this._cssState) {
@@ -412,6 +419,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
return allStates;
}
@profile
public addPseudoClass(name: string): void {
let allStates = this.getAllAliasedStates(name);
for (let i = 0; i < allStates.length; i++) {
@@ -422,6 +430,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
}
}
@profile
public deletePseudoClass(name: string): void {
let allStates = this.getAllAliasedStates(name);
for (let i = 0; i < allStates.length; i++) {
@@ -432,6 +441,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
}
}
@profile
private _applyInlineStyle(inlineStyle) {
if (typeof inlineStyle === "string") {
try {
@@ -504,6 +514,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
}
}
@profile
public requestLayout(): void {
let parent = this.parent;
if (parent) {
@@ -515,6 +526,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
//
}
@profile
public _addView(view: ViewBase, atIndex?: number) {
if (traceEnabled()) {
traceWrite(`${this}._addView(${view}, ${atIndex})`, traceCategories.ViewHierarchy);
@@ -535,6 +547,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
view._parentChanged(null);
}
@profile
private _setStyleScope(scope: ssm.StyleScope): void {
this._styleScope = scope;
this._applyStyleFromScope();
@@ -623,6 +636,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
}
}
@profile
public _setupUI(context: android.content.Context, atIndex?: number, parentIsLoaded?: boolean) {
traceNotifyEvent(this, "_setupUI");
if (traceEnabled()) {
@@ -701,6 +715,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
});
}
@profile
public _tearDownUI(force?: boolean) {
// No context means we are already teared down.
if (!this._context) {

View File

@@ -17,6 +17,7 @@ import {
rotateProperty, scaleXProperty, scaleYProperty, translateXProperty, translateYProperty,
zIndexProperty, backgroundInternalProperty
} from "../../styling/style-properties";
import { profile } from "../../../profiling";
export * from "./view-common";
@@ -82,11 +83,13 @@ export class View extends ViewCommon {
}
}
@profile
public onLoaded() {
super.onLoaded();
this.setOnTouchListener();
}
@profile
public onUnloaded() {
if (this.touchListenerIsSet) {
this.nativeView.setOnTouchListener(null);
@@ -132,6 +135,7 @@ export class View extends ViewCommon {
}
}
@profile
public requestLayout(): void {
super.requestLayout();
if (this.nativeView) {

View File

@@ -6,7 +6,6 @@ import {
ViewCommon, layout, isEnabledProperty, originXProperty, originYProperty, automationTextProperty, isUserInteractionEnabledProperty,
traceEnabled, traceWrite, traceCategories
} from "./view-common";
import {
Visibility,
visibilityProperty, opacityProperty,
@@ -14,6 +13,7 @@ import {
translateXProperty, translateYProperty, zIndexProperty,
backgroundInternalProperty, clipPathProperty
} from "../../styling/style-properties";
import { profile } from "../../../profiling";
export * from "./view-common";
@@ -80,6 +80,7 @@ export class View extends ViewCommon {
}
}
@profile
public layout(left: number, top: number, right: number, bottom: number): void {
let { boundsChanged, sizeChanged } = this._setCurrentLayoutBounds(left, top, right, bottom);
this.layoutNativeView(left, top, right, bottom);
@@ -100,6 +101,7 @@ export class View extends ViewCommon {
this._privateFlags |= PFLAG_MEASURED_DIMENSION_SET;
}
@profile
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
const view = this.nativeView;
const width = layout.getMeasureSpecSize(widthMeasureSpec);