-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display list of non-deleted WebGL objects #195
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { WebGlConstants, WebGlConstantsByValue } from "../types/webglConstants"; | |
import { FunctionCallbacks, IFunctionInformation } from "../types/functionInformation"; | ||
import { ICapture } from "../../shared/capture/capture"; | ||
import { WebGlObjects } from "../webGlObjects/baseWebGlObject"; | ||
import {StackTrace} from "../../shared/utils/stackTrace"; | ||
|
||
export interface IRecorder { | ||
registerCallbacks(onFunctionCallbacks: FunctionCallbacks): void; | ||
|
@@ -85,6 +86,8 @@ export abstract class BaseRecorder<T extends WebGLObject> implements IRecorder { | |
protected readonly startTime: number; | ||
protected readonly memoryPerSecond: { [second: number]: number }; | ||
|
||
private objects: { [id: number]: WeakRef<WebGLObject> }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be called |
||
|
||
private totalMemory: number; | ||
private frameMemory: number; | ||
private capturing: boolean; | ||
|
@@ -131,6 +134,22 @@ export abstract class BaseRecorder<T extends WebGLObject> implements IRecorder { | |
public appendRecordedInformation(capture: ICapture): void { | ||
capture.frameMemory[this.objectName] = this.frameMemory; | ||
capture.memory[this.objectName] = this.memoryPerSecond; | ||
capture.objects[this.objectName] = {}; | ||
for (const id in this.objects) { | ||
if (this.objects.hasOwnProperty(id)) { | ||
const object = this.objects[id].deref(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea of a However, objects which no longer exist must also have their There are also Thoughts? |
||
if (object) { | ||
const source = WebGlObjects.getWebGlObjectSource(object); | ||
if (source) { | ||
capture.objects[this.objectName][id] = source; | ||
} else { | ||
console.log("Object without source"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This currently doesn't pass the linter. |
||
} | ||
} else { | ||
console.log("Object which was already free'd"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This currently doesn't pass the linter. |
||
} | ||
} | ||
} | ||
} | ||
|
||
protected abstract getCreateCommandNames(): string[]; | ||
|
@@ -141,7 +160,19 @@ export abstract class BaseRecorder<T extends WebGLObject> implements IRecorder { | |
protected abstract delete(instance: T): number; | ||
|
||
protected create(functionInformation: IFunctionInformation): void { | ||
// Nothing tracked currently on create. | ||
// Removes the spector internal calls to leave only the relevant part. | ||
const stackTrace = StackTrace.getStackTrace(5, 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The range for this |
||
|
||
const createdWebGlObject = functionInformation.result as T; | ||
|
||
// Add information where this object was created | ||
WebGlObjects.attachWebGlObjectSource(createdWebGlObject, stackTrace); | ||
|
||
// Add our object to the list of tracked objects (object should only exist once). | ||
const tag = WebGlObjects.getWebGlObjectTag(createdWebGlObject); | ||
this.objects = this.objects || []; | ||
if (this.objects[tag.id]) { debugger; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This currently doesn't pass the linter. (A similar case already existed in |
||
this.objects[tag.id] = new WeakRef(createdWebGlObject); | ||
} | ||
|
||
protected createWithoutSideEffects(functionInformation: IFunctionInformation): void { | ||
|
@@ -186,6 +217,16 @@ export abstract class BaseRecorder<T extends WebGLObject> implements IRecorder { | |
} | ||
|
||
this.options.toggleCapture(false); | ||
|
||
const tag = WebGlObjects.getWebGlObjectTag(instance); | ||
if (!tag) { | ||
this.options.toggleCapture(true); | ||
return; | ||
} | ||
|
||
// Remove object from list of objects | ||
delete this.objects[tag.id]; | ||
|
||
const size = this.delete(instance); | ||
this.changeMemorySize(-size); | ||
this.options.toggleCapture(true); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,6 +263,7 @@ export abstract class BaseState { | |
|
||
return { | ||
__SPECTOR_Object_TAG: WebGlObjects.getWebGlObjectTag(object) || this.options.tagWebGlObject(object), | ||
__SPECTOR_Object_Source: WebGlObjects.getWebGlObjectSource(object), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is dead code now? If not, this should be |
||
__SPECTOR_Object_CustomData: object.__SPECTOR_Object_CustomData, | ||
__SPECTOR_Metadata: object.__SPECTOR_Metadata, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ export type WebGlObjectTag = { | |
customData?: any; | ||
}; | ||
|
||
export type WebGlObjectSource = string[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead, this should be an object which also stores when the object was created. |
||
|
||
export class WebGlObjects { | ||
public static getWebGlObjectTag(object: WebGLObject): WebGlObjectTag { | ||
return (object as any)[WebGlObjects.SPECTOROBJECTTAGKEY]; | ||
|
@@ -22,7 +24,16 @@ export class WebGlObjects { | |
return `${tag.typeName} - ID: ${tag.id}`; | ||
} | ||
|
||
public static getWebGlObjectSource(object: WebGLObject): WebGlObjectSource { | ||
return (object as any)[WebGlObjects.SPECTOROBJECTSOURCEKEY]; | ||
} | ||
|
||
public static attachWebGlObjectSource(object: WebGLObject, source: WebGlObjectSource): void { | ||
(object as any)[WebGlObjects.SPECTOROBJECTSOURCEKEY] = source; | ||
} | ||
|
||
private static readonly SPECTOROBJECTTAGKEY = "__SPECTOR_Object_TAG"; | ||
private static readonly SPECTOROBJECTSOURCEKEY = "__SPECTOR_Object_SOURCE"; | ||
} | ||
|
||
// tslint:disable-next-line:max-classes-per-file | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -407,6 +407,8 @@ export class ResultView { | |
} | ||
this.displayJSONGroup(rightJsonContentStateId, "Frame Memory Changes", capture.frameMemory); | ||
this.displayJSONGroup(rightJsonContentStateId, "Total Memory (seconds since application start: bytes)", capture.memory); | ||
this.displayJSONGroup(rightJsonContentStateId, "Objects", capture.objects); | ||
|
||
} | ||
|
||
private displayJSON(parentGroupId: number, json: any) { | ||
|
@@ -501,6 +503,10 @@ export class ResultView { | |
return null; | ||
} | ||
|
||
if (json.__SPECTOR_Object_SOURCE) { | ||
return json.__SPECTOR_Object_SOURCE; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this ever did anything. I'd like to display the origin somewhere in the command list detail pane, too. I simply wasn't sure how to do it (I have a lot of trouble understanding the codebase to be honest). |
||
|
||
if (json.__SPECTOR_Object_TAG) { | ||
return json.__SPECTOR_Object_TAG.displayText; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,10 @@ | |
"experimentalDecorators": true, | ||
"module": "es6", | ||
"moduleResolution": "node", | ||
"target": "es5" | ||
"target": "es5", | ||
"lib": [ | ||
"ESNext", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was necessary for |
||
"dom" | ||
] | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: missing spaces