Bug 184990

Summary: Web Inspector: Canvas tab: Determine isFunction by looking at the prototype
Product: WebKit Reporter: Devin Rousso <drousso>
Component: Web InspectorAssignee: Devin Rousso <drousso>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, commit-queue, ews-watchlist, inspector-bugzilla-changes, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Bug Depends on: 182995    
Bug Blocks: 173807    
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews103 for mac-sierra
none
Archive of layout-test-results from ews106 for mac-sierra-wk2
none
Archive of layout-test-results from ews114 for mac-sierra
none
Patch
none
Archive of layout-test-results from ews200 for win-future none

Description Devin Rousso 2018-04-25 12:51:17 PDT
Instead of maintaining a static list of function calls on the different canvas context types, we can just look at the prototype to determine if a given key resolves to a function.
Comment 1 Devin Rousso 2018-04-25 12:57:34 PDT
Created attachment 338771 [details]
Patch
Comment 2 EWS Watchlist 2018-05-01 17:46:29 PDT Comment hidden (obsolete)
Comment 3 EWS Watchlist 2018-05-01 17:46:30 PDT Comment hidden (obsolete)
Comment 4 EWS Watchlist 2018-05-01 18:26:39 PDT Comment hidden (obsolete)
Comment 5 EWS Watchlist 2018-05-01 18:26:40 PDT Comment hidden (obsolete)
Comment 6 EWS Watchlist 2018-05-01 19:23:45 PDT Comment hidden (obsolete)
Comment 7 EWS Watchlist 2018-05-01 19:23:46 PDT Comment hidden (obsolete)
Comment 8 Devin Rousso 2018-05-01 22:02:24 PDT
Created attachment 339276 [details]
Patch
Comment 9 EWS Watchlist 2018-05-02 00:36:17 PDT Comment hidden (obsolete)
Comment 10 EWS Watchlist 2018-05-02 00:36:29 PDT Comment hidden (obsolete)
Comment 11 Devin Rousso 2018-05-02 00:49:02 PDT
Comment on attachment 339287 [details]
Archive of layout-test-results from ews200 for win-future

Unrelated failure
Comment 12 BJ Burg 2018-05-03 09:27:34 PDT
Comment on attachment 339276 [details]
Patch

r=me

How often is this code called? Does it affect performance to dynamically look up for every call, rather than using a fixed Set lookup?
Comment 13 Devin Rousso 2018-05-03 16:17:17 PDT
(In reply to Brian Burg from comment #12)
> How often is this code called? Does it affect performance to dynamically
> look up for every call, rather than using a fixed Set lookup?
`WI.RecoringAction.isFunctionForType` is called once per `WI.RecordingAction` (assuming it has been `swizzle()`d), and is called for each value in the `WI.Recording`'s `initialState.attributes`.  I think a good middle-ground would be to keep the `WI.RecordingAction._functionNames` object, but have it be filled with values as each action is processed (sort of like a memoization).
Comment 14 BJ Burg 2018-05-03 16:52:44 PDT
(In reply to Devin Rousso from comment #13)
> (In reply to Brian Burg from comment #12)
> > How often is this code called? Does it affect performance to dynamically
> > look up for every call, rather than using a fixed Set lookup?
> `WI.RecoringAction.isFunctionForType` is called once per
> `WI.RecordingAction` (assuming it has been `swizzle()`d), and is called for
> each value in the `WI.Recording`'s `initialState.attributes`.  I think a
> good middle-ground would be to keep the `WI.RecordingAction._functionNames`
> object, but have it be filled with values as each action is processed (sort
> of like a memoization).

If you can capture a profile during the initial setup, and you can't see this code, then don't bother optimizing it.
Comment 15 Devin Rousso 2018-05-04 11:23:31 PDT
(In reply to Brian Burg from comment #14)
> (In reply to Devin Rousso from comment #13)
> > (In reply to Brian Burg from comment #12)
> > > How often is this code called? Does it affect performance to dynamically
> > > look up for every call, rather than using a fixed Set lookup?
> > `WI.RecoringAction.isFunctionForType` is called once per
> > `WI.RecordingAction` (assuming it has been `swizzle()`d), and is called for
> > each value in the `WI.Recording`'s `initialState.attributes`.  I think a
> > good middle-ground would be to keep the `WI.RecordingAction._functionNames`
> > object, but have it be filled with values as each action is processed (sort
> > of like a memoization).
> 
> If you can capture a profile during the initial setup, and you can't see
> this code, then don't bother optimizing it.
I was able to get a profile of it while recording the canvas on <http://acko.net> and it only took 0.1ms.  The worst I've seen so far (100k actions) was 0.9ms.  I think it's fine as is.
Comment 16 WebKit Commit Bot 2018-05-04 11:50:36 PDT
Comment on attachment 339276 [details]
Patch

Clearing flags on attachment: 339276

Committed r231368: <https://trac.webkit.org/changeset/231368>
Comment 17 WebKit Commit Bot 2018-05-04 11:50:38 PDT
All reviewed patches have been landed.  Closing bug.
Comment 18 Radar WebKit Bug Importer 2018-05-04 11:52:35 PDT
<rdar://problem/39984315>