Bug 151116

Summary: Web Inspector: Code coverage profiler: incorrect "in-viewport" detection algorithm
Product: WebKit Reporter: Nikita Vasilyev <nvasilyev>
Component: Web InspectorAssignee: Nikita Vasilyev <nvasilyev>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, commit-queue, graouts, joepeck, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 9   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch none

Nikita Vasilyev
Reported 2015-11-10 12:21:18 PST
The following "is block in the viewport" code is incorrect: basicBlocks = basicBlocks.filter(function(block) { return (block.startOffset >= startOffset && block.startOffset <= endOffset) || (block.startOffset <= startOffset && block.endOffset >= endOffset); }); https://github.com/WebKit/webkit/blob/f70c51a855acc626ec921f7400a69ede4bffac96/Source/WebInspectorUI/UserInterface/Controllers/BasicBlockAnnotator.js#L68-L71 Let's break it down into smaller pieces: block.startOffset >= startOffset && block.startOffset <= endOffset returns true for the following cases (tilt your head 90 degrees): Viewport: [---] Block: [---] block.startOffset <= startOffset && block.endOffset >= endOffset returns true for the following case: Viewport: [---] Block: [------] The following case isn't covered, e.g. the filter function wrongly returns false: Viewport: [---] Block: [---]
Attachments
Patch (1.87 KB, patch)
2015-11-10 12:39 PST, Nikita Vasilyev
no flags
Radar WebKit Bug Importer
Comment 1 2015-11-10 12:21:50 PST
Nikita Vasilyev
Comment 2 2015-11-10 12:31:21 PST
Let's outline all the possible scenarios. Intersect: A: [---] B: [---] A: [-----] B: [-] A: [-] B: [-----] A: [---] B: [---] Don't intersect: A: [---] B: [---] A: [---] B: [---] The easiest way to check if two ranges intersect is to check if they don't intersect. It is also the fastest way.
Nikita Vasilyev
Comment 3 2015-11-10 12:39:26 PST
Blaze Burg
Comment 4 2015-11-10 12:51:06 PST
Comment on attachment 265220 [details] Patch r=me
WebKit Commit Bot
Comment 5 2015-11-10 13:39:58 PST
Comment on attachment 265220 [details] Patch Clearing flags on attachment: 265220 Committed r192264: <http://trac.webkit.org/changeset/192264>
WebKit Commit Bot
Comment 6 2015-11-10 13:40:01 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.