RESOLVED FIXED 177583
Add debug flag to WebKitTestRunner to show where touches are being generated
https://bugs.webkit.org/show_bug.cgi?id=177583
Summary Add debug flag to WebKitTestRunner to show where touches are being generated
Megan Gardner
Reported 2017-09-27 17:14:39 PDT
Add debug flag to WebKitTestRunner to show where touches are being generated
Attachments
Patch (16.79 KB, patch)
2017-09-27 17:16 PDT, Megan Gardner
no flags
Patch (15.45 KB, patch)
2017-09-27 18:06 PDT, Megan Gardner
no flags
Patch (14.83 KB, patch)
2017-09-27 18:57 PDT, Megan Gardner
simon.fraser: review-
Patch (14.99 KB, patch)
2017-09-28 11:08 PDT, Megan Gardner
simon.fraser: review-
Megan Gardner
Comment 1 2017-09-27 17:16:58 PDT
Tim Horton
Comment 2 2017-09-27 17:33:30 PDT
Comment on attachment 322046 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=322046&action=review > Tools/WebKitTestRunner/Options.cpp:139 > optionList.append(Option("--show-webview", "Show the WebView during test runs (for Debugging)", handleOptionShowWebView)); > + optionList.append(Option("--show-touches", "Show the touches during test runs (for Debugging)", handleOptionShowTouches)); both of these "debugging" should be lower case > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:84 > +static const NSUInteger debugTouchDotFrame = debugTouchDotRadius*2; Spaces around operators! > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:157 > +-(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { // Never react to touches Can't you just view.userInteractionEnabled=NO? Then you don't even need this subclass. Also, brace should be on the next line, and remove the comment. > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:217 > + self.debugTouchViews = @[[[DebugTouchView alloc] initWithFrame:CGRectMake(10, 10, debugTouchDotFrame, debugTouchDotFrame)], Can this be a loop that uses maxTouchCount, instead? > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:322 > +- (void)updateDebugUI:(UInt)index withPoint:(CGPoint)point isTouching:(BOOL)isTouching should probably be updateDebugIndicatorForTouch or something, not "DebugUI" > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:569 > + if (self.shouldShowTouches) { Why do some of these not use the helper? Then you could put the initDebugViews call inside the helper?
Megan Gardner
Comment 3 2017-09-27 18:06:01 PDT
Tim Horton
Comment 4 2017-09-27 18:15:46 PDT
Comment on attachment 322049 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=322049&action=review > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:162 > + BOOL _shouldInitDebugViews; Do we need this, or can we just check debugTouchViews? > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:200 > + if ([[UIApplication sharedApplication] keyWindow]) > + [self initDebugViews]; > + else Is there any reason to eagerly do it at this point? We don't support dynamically changing it (e.g. nothing ever removes views), which is fine, so shouldn't we just depend on the lazy loading mechanism always? > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:205 > +- (void)initDebugViews This is now an "-IfNeeded" > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:207 > + if (self.shouldShowTouches && _shouldInitDebugViews) { Should be an early return :)
Megan Gardner
Comment 5 2017-09-27 18:57:34 PDT
Tim Horton
Comment 6 2017-09-28 01:18:36 PDT
Comment on attachment 322055 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=322055&action=review > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:84 > +static const NSUInteger debugTouchDotFrame = debugTouchDotRadius * 2; “Frame”? Isn’t this a size? Frame is usually a rect.
Wenson Hsieh
Comment 7 2017-09-28 08:50:40 PDT
Comment on attachment 322055 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=322055&action=review > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:201 > + UIView *newView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, debugTouchDotFrame, debugTouchDotFrame)]; It looks like newView is leaked here. Perhaps we should use something like: auto newView = adoptNS([[UIView alloc] initWithFrame:CGRectMake(10, 10, debugTouchDotSize, debugTouchDotSize)]); (or alternately, we can just manually call -release) > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:209 > + self.debugTouchViews = [NSArray arrayWithArray:debugViews]; I think we can just do `self.debugTouchViews = debugViews;` here? (Since an NSMutableArray is a kind of NSArray).
Megan Gardner
Comment 8 2017-09-28 11:08:52 PDT
Simon Fraser (smfr)
Comment 9 2017-09-28 13:46:52 PDT
Comment on attachment 322055 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=322055&action=review > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:204 > + newView.backgroundColor = [UIColor colorWithRed:1.0-i*.05 green:0.0 blue:1.0-i*.05 alpha:0.5]; Spaces around operators. > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:207 > + [[[UIApplication sharedApplication] keyWindow] addSubview:newView]; Uh, this seems a bit random. I think we should explicitly pass a view to add them to so we know the coordinate system is correct. > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:299 > +- (void)updateDebugIndicatorForTouch:(UInt)index withPoint:(CGPoint)point isTouching:(BOOL)isTouching Point In what coordinate system? Method name should make that clear. > Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:338 > + if (self.shouldShowTouches) > + [self updateDebugIndicatorForTouch:[touchInfo[HIDEventTouchIDKey] intValue] withPoint:CGPointMake([touchInfo[HIDEventXKey] floatValue], [touchInfo[HIDEventYKey] floatValue]) isTouching:(BOOL)touch]; I don't think HIDEventGenerator should be in the business of doing UIView stuff. I think this code should move somewhere else.
Simon Fraser (smfr)
Comment 10 2017-09-28 13:47:27 PDT
Comment on attachment 322101 [details] Patch r- for reasons in previous patch.
Megan Gardner
Comment 11 2017-09-28 14:00:49 PDT
Comment on attachment 322055 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=322055&action=review >> Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:207 >> + [[[UIApplication sharedApplication] keyWindow] addSubview:newView]; > > Uh, this seems a bit random. I think we should explicitly pass a view to add them to so we know the coordinate system is correct. Maybe I don't understand HID stuff, but I thought by this time they were in global coordinate space? If that's not the case (and it sounds like it's not), then how can we determine what view these touches were meant for? >> Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:338 >> + [self updateDebugIndicatorForTouch:[touchInfo[HIDEventTouchIDKey] intValue] withPoint:CGPointMake([touchInfo[HIDEventXKey] floatValue], [touchInfo[HIDEventYKey] floatValue]) isTouching:(BOOL)touch]; > > I don't think HIDEventGenerator should be in the business of doing UIView stuff. I think this code should move somewhere else. Where do you suggest? We do a lot of work here to determine where the touches are going to be, and this is just for debugging. It's not even on all the time, only the you actually turn it on.
Simon Fraser (smfr)
Comment 12 2017-09-30 12:02:18 PDT
(In reply to Megan Gardner from comment #11) > Comment on attachment 322055 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=322055&action=review > > >> Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:207 > >> + [[[UIApplication sharedApplication] keyWindow] addSubview:newView]; > > > > Uh, this seems a bit random. I think we should explicitly pass a view to add them to so we know the coordinate system is correct. > > Maybe I don't understand HID stuff, but I thought by this time they were in > global coordinate space? If that's not the case (and it sounds like it's > not), then how can we determine what view these touches were meant for? The issue here isn't necessarily that you're not adding the dots in the view that the events are targeted at, but that you have no idea about the geometry of [[UIApplication sharedApplication] keyWindow]. Maybe it's some small view owned by UIKit at some point, in which case your dots are going to show in the wrong place. I'd suggesting adding a hosting view whose geometry you can rely on, and maybe do this in some UIApplication override? > >> Tools/WebKitTestRunner/ios/HIDEventGenerator.mm:338 > >> + [self updateDebugIndicatorForTouch:[touchInfo[HIDEventTouchIDKey] intValue] withPoint:CGPointMake([touchInfo[HIDEventXKey] floatValue], [touchInfo[HIDEventYKey] floatValue]) isTouching:(BOOL)touch]; > > > > I don't think HIDEventGenerator should be in the business of doing UIView stuff. I think this code should move somewhere else. > > Where do you suggest? We do a lot of work here to determine where the > touches are going to be, and this is just for debugging. It's not even on > all the time, only the you actually turn it on. It's not the runtime cost that I object to, but the code cleanliness.
Megan Gardner
Comment 13 2017-10-02 17:23:42 PDT
Offensive part cleaned up and broken out into it's own file in: https://bugs.webkit.org/show_bug.cgi?id=177796
Megan Gardner
Comment 14 2018-05-09 13:28:55 PDT
https://trac.webkit.org/changeset/222631/webkit This was committed before Simon's R-. The concerns he raised were fixed in https://bugs.webkit.org/show_bug.cgi?id=177796
Radar WebKit Bug Importer
Comment 15 2018-05-09 14:03:04 PDT
Note You need to log in before you can comment on or make changes to this bug.