Skip to content
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 external hook for mousemove event #196

Open
soulgalore opened this issue Apr 2, 2017 · 12 comments
Open

Add external hook for mousemove event #196

soulgalore opened this issue Apr 2, 2017 · 12 comments

Comments

@soulgalore
Copy link
Collaborator

soulgalore commented Apr 2, 2017

It would be super cool to open up for users of PerfCascade to add screenshots that change depending on where the mouse hovers on the graph. It would be a perfect fit for sitespeed.io if we could have events reporting the timing (or is there a better way to do it?). See #193 (comment)

@micmro micmro changed the title Report the time on mouse events on the graph (please re-phrase :)) Add external hook for mousemove event Apr 4, 2017
@micmro
Copy link
Owner

micmro commented Apr 4, 2017

mousemove is always a bit performance sensitive, so we should only setup eventListener for mousemove event when external hook is present.

should should have signature like: (hoverPositionMs: number, OriginalEvt: MouseEvent) => void.

I suppose getting this to work with touch would be bit of a pain.

@tobli
Copy link
Collaborator

tobli commented Apr 4, 2017

Another way might be to create regions (e.g. transparent svg rects) of configurable widths, and attach mouseenter/leave listeners. If you have a screenshot every 500ms, you ask for slices (and thereby events) at intervals of whatever 500ms corresponds to.

@soulgalore
Copy link
Collaborator Author

I think you wanna match screenshots with the exact timeline in PerfCascade. So when firstPaint really happens you wanna see that. VisualMetrics today creates screenshots for every change that happens and I think we will do the same right?

@tobli
Copy link
Collaborator

tobli commented Apr 4, 2017

Sure, even slices was a simplified example. You'd ask for the intervals you need/have data for.
setItUp([0, 48, 52, 120, 287, 1204]), ...)

@soulgalore
Copy link
Collaborator Author

yep cool.

@micmro micmro self-assigned this Jun 11, 2017
micmro pushed a commit that referenced this issue Jun 24, 2017
@micmro
Copy link
Owner

micmro commented Jun 24, 2017

Hi @soulgalore & @tobli
Can you check out the 196 branch to see if this would work for your use-case?

{
   ...
   timeSlices: [0, 750, 1300],
   timeSliceOnEnter: (slice, evt) => {console.log("timeSliceOnEnter", slice, evt)},
   timeSliceOnLeave: (slice, evt) => {console.log("timeSliceOnLeave", slice, evt)}
}

I tried the overlays @tobli had suggested but I totally forgot that the events on items below will not fire (could not find any good work-around).
I used a passive (when available) mousemove listener for hit-tests instead - tested it and it did take:
< 100 µs (chrome/MBP)
< 0.1ms (FF/MBP)
< 0.7ms in chrome with 20x CPU throttling
so I think it should be fine perf-wise.

@soulgalore
Copy link
Collaborator Author

thank you @micmro - super cool, I'll try it tonight!

@soulgalore
Copy link
Collaborator Author

Or I tried now :) I got an error when I tried to get it up and running:

npm run watch
...
>> TypeScript error: src/ts/waterfall/row/svg-row-subcomponents.ts(40,7): Error TS2322: Type 'Timer' is not assignable to type 'number'.

@soulgalore
Copy link
Collaborator Author

My fault, I cleaned node_modules ad installed again and it worked. Been trying out npm5 but it does do so good for me.

@soulgalore
Copy link
Collaborator Author

I've been trying out different scenarios and I think I was wrong from the beginning. I have a hard time to figure out how the GUI would work, how we can make sure that you see the screenshot at the same time as you move the mouse over the waterfall. The waterfall could be so high so you need then to display the screenshot on top of the waterfall and I'm not sure that it would look good (need to find us a GUI person :)). WebPageTest do the other way around: You scroll the images and then draw a line over the waterfall https://www.webpagetest.org/video/compare.php?tests=170624_92_ZC2-r%3A1-c%3A0&thumbSize=200&ival=100&end=visual

I think we need to discuss how we wanna do before you do too much @micmro !

Ping @tobli and @beenanner .

@micmro
Copy link
Owner

micmro commented Jun 25, 2017

Cool, np at all.

I have not though about it too much but how about something like this (very rough outline)?:
If you get the exact mouse x-position you could keep a preview in an overlay following the mouse (above the PerfCascade chart, but letting though mouse-events), this could position itself relative to the viewport on the y-axis, so large HARs would work as well.
There are some perf considerations, but just as an idea.

196-example

@soulgalore
Copy link
Collaborator Author

@micmro ah yes sounds like a really good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants