{"action":"created","issue":{"url":"https://api.github.com/repos/whatwg/console/issues/120","repository_url":"https://api.github.com/repos/whatwg/console","labels_url":"https://api.github.com/repos/whatwg/console/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/whatwg/console/issues/120/comments","events_url":"https://api.github.com/repos/whatwg/console/issues/120/events","html_url":"https://github.com/whatwg/console/issues/120","id":270466905,"number":120,"title":"Add console.record and console.recordEnd","user":{"login":"dcrousso","id":4356609,"avatar_url":"https://avatars1.githubusercontent.com/u/4356609?v=4","gravatar_id":"","url":"https://api.github.com/users/dcrousso","html_url":"https://github.com/dcrousso","followers_url":"https://api.github.com/users/dcrousso/followers","following_url":"https://api.github.com/users/dcrousso/following{/other_user}","gists_url":"https://api.github.com/users/dcrousso/gists{/gist_id}","starred_url":"https://api.github.com/users/dcrousso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcrousso/subscriptions","organizations_url":"https://api.github.com/users/dcrousso/orgs","repos_url":"https://api.github.com/users/dcrousso/repos","events_url":"https://api.github.com/users/dcrousso/events{/privacy}","received_events_url":"https://api.github.com/users/dcrousso/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-11-01T21:58:49Z","updated_at":"2017-11-01T23:45:54Z","closed_at":null,"author_association":"NONE","body":"WebKit has added support for being able to record actions performed to a `HTMLCanvasElement`, `CanvasRenderingContext2D`, and `WebGLRenderingContext` via a Canvas tab in the WebInspector frontend [1].  We are also prototyping a way for these recordings to be triggered via JavaScript, specifically through `console.record` and `console.recordEnd` [2].  `record` and `recordEnd` do not need to be limited to canvases,  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.\r\n\r\nThe proposal is to support the following:\r\n```\r\nconsole.record(object, [options]);\r\nconsole.recordEnd(object);\r\n```\r\nwhere `object` is any JavaScript object and the optional `options` would be a dictionary of configuration values.  Neither function would have any return value or throw an exception, instead silently failing if no WebInspector frontend exists or if `object` is already being recorded.\r\n\r\nThe keys we currently support for `options` are:\r\n```\r\nname: String\r\nsingleFrame: Boolean\r\nmemoryLimit: Integer\r\n```\r\n - `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).\r\n - `singleFrame` indicates whether the recording should automatically stop after one frame (`recordEnd` can still end the recording early)\r\n - `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 data\r\n\r\nI don't think that these options should be required, and I am listing them here more so for greater explanation/understanding.\r\n\r\nThe 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:\r\n```js\r\nlet ctx = document.createElement(\"canvas\").getContext(\"2d\");\r\n\r\nconsole.record(ctx, {name: \"Line\"});\r\nctx.moveTo(10, 10);\r\nctx.lineTo(20, 20);\r\nctx.stroke();\r\nconsole.recordEnd(ctx);\r\n\r\nconsole.record(ctx, {name: \"Box\"});\r\nctx.fillRect(20, 20, 10, 10);\r\nconsole.recordEnd(ctx);\r\n```\r\nAfter 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.\r\n\r\n[1] [Web Inspector: [META] Allow canvas actions to be recorded/replayed](https://webkit.org/b/173807)\r\n[2] [Web Inspector: provide method for recording CanvasRenderingContext2D from JavaScript](https://webkit.org/b/175166)"},"comment":{"url":"https://api.github.com/repos/whatwg/console/issues/comments/341276350","html_url":"https://github.com/whatwg/console/issues/120#issuecomment-341276350","issue_url":"https://api.github.com/repos/whatwg/console/issues/120","id":341276350,"user":{"login":"domenic","id":617481,"avatar_url":"https://avatars0.githubusercontent.com/u/617481?v=4","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"created_at":"2017-11-01T23:45:54Z","updated_at":"2017-11-01T23:45:54Z","author_association":"OWNER","body":"/cc @whatwg/canvas just in case any of the implementers there are super-enthused about this idea for their own canvas/devtools interaction.\r\n\r\nI 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."}}
{"actor":{"display_login":"domenic"}}