-
Notifications
You must be signed in to change notification settings - Fork 71
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
Add console.record
and console.recordEnd
#120
Comments
Admittedly my backlog (of mostly school right now :(... ) is fairly substantial but I will dig into this more as soon as I can! From a brief look though, it seems like a bit of a compatibility issue perhaps. Typically we'd prefer to have a couple major vendors commit to implementing a feature before landing it in the spec, and it sounds like (again, I have not dug into the above links or conversations) this is a WebKit-specific feature right now that does not return anything or throw so that it can be "compatible" right out of the bat (other impls technically don't break). This is perfect for Node since we don't have elaborate UI functionality that we can trigger via the console object, but I have a feeling we might want to get other implementations on board (or at least looking at it) before adding to spec? Then again it is mainly just UI stuff that doesn't affect other spec'd stuff so....hmm. My judgement on this might not be great though, so in the meantime @domenic might have some good insight! |
Could you elaborate on that? Compatibility issues when introducing new APIs in Web Standards normally falls into a few buckets:
I don't think either apply here.
Yep, that is exactly what this issue is meant to encourage. We (WebKit) would like to hear if any other browsers / browser tools have an interest in a feature like this, and if so maybe refining the name / API to work more generally for cases we hadn't thought of or considered. Further, I think strict compatibility of functions on Console is probably held to a lower bar than other APIs. At least on the Web, many Console APIs are tools used by developers in development when debugging or investigating issues ( WebKit's initial use case with Canvas recordings is a natural first application because we have the ability to make a recording of a canvas element / context in the tools. But you could imagine developer tools being able to "record" other objects, and having a common way to programmatically start/stop a recording for any kind of object would be nice. Here are some examples off the top of my head for other Web exposed objects:
I don't know of any tools that provide these kinds of debugging capabilities, but the proposed API would be sufficient to make this possible. In the same way that At a pure JavaScript Context level (e.g. node.js) I haven't thought of any compelling use cases for this yet. JavaScriptCore's JSContext implementation of |
/cc @whatwg/canvas just in case any of the implementers there are super-enthused about this idea for their own canvas/devtools interaction. I think the primary concern is indeed making sure other environments are at least interested in adding a no-op function; that shouldn't be too high of a bar. Ideally they'd be interested in using this in more areas. Perhaps on the Chrome side @paulirish has some thoughts. |
@JosephPecoraro In addition to exposed objects, logging changes to a POJO would be appreciated. I've had to wire up setters and observers in the past for similar functionality. I wouldn't be against adding it here if other implementations are keen. |
Is that a "Plain Old JavaScript Object"? Yeah, I suspect logging modifications / accesses to a single object is possible in pure JavaScript with Proxy, but having tools make a task like that easier (without having to make a Proxy) would be nice for developers. My opinion right now is that such a tool shouldn't be Without derailing too much. A feature like But this is the start of a healthy discussion. I think an implementation could totally make NOTE: I'm not proposing anything like |
Some folks that may be interested: @auchenberg, @Fishrock123 |
My hope is that other environments wouldn't add a no-op function but would find use cases that are appropriate to their tools, particularly if there are things that the user has to start/stop manually. In my opinion adding a no-op function would actually be worse then developers feature checking Chrome and Firefox have the ability to start/stop recording network traffic. I think an unwritten goal here is that I don't want to see a long list of one off |
Similar to what @JosephPecoraro is saying, I see I also agree in that My thinking is that |
Agreed, sorry if I came off wrong. What you said makes sense. I agree with the usefulness of this feature, and am too willing to add if a few implementations are as well. cc'ing @xirzec for Edge as well. Also wondering if @nchevobbe or @bgrins might have any thoughts. |
My initial thought is that the API as it is laid out here seems to handle many different things, which are not really linked:
All this cases would need different UIs to be consumed, and I guess this would require the user to remember each usage depending on what they pass as a first argument to I can see the benefits of these in isolation, but it seems a bit blurry how this would fit under the same API. However, I can see the point of a global |
Personally, I think this sounds pretty neat, though I am curious about the scenario that motivated this API. Was the WebKit team having trouble debugging canvas issues? Were developers clamoring for a way for logging without needing to write their own layer of indirection around it? As others have mentioned, it seems like various platform features would need to implement meaningful logging for this to be useful. Perhaps we could do something generic like have console.record access a method exposed by a particular Symbol on the object, that would instruct the object to begin logging (say by passing in a logging callback function in addition to the user-specified options.) Then both platform objects and user-created objects could decide to participate without needing to make changes to the console itself. |
console.record
and console.recordEnd
WebKit has added support for being able to record actions performed to a
HTMLCanvasElement
,CanvasRenderingContext2D
, andWebGLRenderingContext
via a Canvas tab in the Web Inspector frontend [1]. We are also prototyping a way for these recordings to be triggered via JavaScript, specifically throughconsole.record
andconsole.recordEnd
[2].console.record
andconsole.recordEnd
do not need to be limited to<canvas>
, however, and we have ideas for using it with other objects, such as DOM nodes or storage objects, although these ideas are very much so just ideas at this point.The proposal is to support the following:
where
object
is any JavaScript object and the optionaloptions
would be a dictionary of configuration values. Neither function would have any return value or throw an exception, instead silently doing nothing if no Web Inspector frontend exists or ifobject
is already being recorded.The keys we currently support for
options
are:name
is used to help distinguish multiple recordings taken, such as to identify a particular segment of logic (e.g. if I want to record the drawing of the background vs an object in the scene).singleFrame
indicates whether the recording should automatically stop after one frame (recordEnd
can still end the recording early)frameCount
is used to limit the recording to a certain number of frames (recordEnd
can still end the recording early)singleFrame
memoryLimit
is used to limit the amount of data that is captured during the recording, and will cause the recording to end if a new action would save more than the allotted amount of dataI don't think that these options should be required, and I am listing them here more so for greater explanation/understanding.
The main use-case of providing this would be to enable developers to identify and record specific sections of logic within a single frame. As an example:
After the last action
fillRect
, two recordings would be available to view/replay: "Line" and "Box". This is a very simple example, but I believe that it is possible to extrapolate the usefulness of this feature to much larger and more complex drawings.[1] Web Inspector: [META] Allow canvas actions to be recorded/replayed
[2] Web Inspector: provide method for recording CanvasRenderingContext2D from JavaScript
The text was updated successfully, but these errors were encountered: