Bug 170608 - ImageDiff: Add CG implementation for new ImageDiff
Summary: ImageDiff: Add CG implementation for new ImageDiff
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 85299
Blocks:
  Show dependency treegraph
 
Reported: 2017-04-07 11:47 PDT by Carlos Garcia Campos
Modified: 2017-05-10 01:16 PDT (History)
8 users (show)

See Also:


Attachments
Patch (26.14 KB, patch)
2017-04-07 11:50 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Rebased patch (26.08 KB, patch)
2017-04-10 04:50 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Rebased patch (26.08 KB, patch)
2017-04-10 05:55 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Fix debug build (26.06 KB, patch)
2017-04-11 06:08 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Include win changes (40.34 KB, patch)
2017-04-11 07:00 PDT, Carlos Garcia Campos
bfulgham: review+
commit-queue: commit-queue-
Details | Formatted Diff | Diff
Rebased patch (39.44 KB, patch)
2017-05-09 06:36 PDT, Carlos Garcia Campos
achristensen: review+
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews122 for ios-simulator-wk2 (8.05 MB, application/zip)
2017-05-09 08:43 PDT, Build Bot
no flags Details
Rebase again after r216504 (39.48 KB, patch)
2017-05-09 08:46 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Try to fix win build (40.32 KB, patch)
2017-05-09 09:06 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Try to fix win build (40.41 KB, patch)
2017-05-09 10:15 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2017-04-07 11:47:26 PDT
In bug #85299 there's a patch to move GTK+ port to use a cairo only image diff. While working on it I realized we have 3 implementations with a lot of duplicated code, so as part of the patch I refactored the code to share all the common code. On top of that patch adding the CG implementations is easy.
Comment 1 Carlos Garcia Campos 2017-04-07 11:50:40 PDT
Created attachment 306522 [details]
Patch
Comment 2 Carlos Garcia Campos 2017-04-10 04:50:59 PDT
Created attachment 306683 [details]
Rebased patch
Comment 3 Carlos Garcia Campos 2017-04-10 05:55:50 PDT
Created attachment 306687 [details]
Rebased patch
Comment 4 Carlos Garcia Campos 2017-04-10 07:02:55 PDT
hmm, the debug failure is because of the ASSERT, doesn't image diff link to WTF already? or am I missing a header include? I can easily fix the build by removing the ASSERT, I guess.
Comment 5 Carlos Garcia Campos 2017-04-11 06:08:12 PDT
Created attachment 306807 [details]
Fix debug build

I have no idea why it fails to build so I've just removed the assert.
Comment 6 Carlos Garcia Campos 2017-04-11 07:00:04 PDT
Created attachment 306812 [details]
Include win changes

I've realized that the patch would break windows, because it removes the ImageDiffCG from DRT. So, this new patch also includes the windows changed that was going to do in a follow up patch. I have no way to test windows changes, so I don't know whether it works or not.
Comment 7 Build Bot 2017-04-11 07:01:39 PDT
Attachment 306812 [details] did not pass style-queue:


ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:37:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 2 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Carlos Garcia Campos 2017-04-21 01:49:39 PDT
Ping reviewers
Comment 9 Brent Fulgham 2017-04-21 12:39:49 PDT
This builds and seems to work locally.
Comment 10 Brent Fulgham 2017-04-21 12:40:56 PDT
Comment on attachment 306812 [details]
Include win changes

Looks good, and works properly on Windows (at least locally). Let's land it.
Comment 11 Carlos Garcia Campos 2017-04-22 00:37:07 PDT
(In reply to Brent Fulgham from comment #10)
> Comment on attachment 306812 [details]
> Include win changes
> 
> Looks good, and works properly on Windows (at least locally). Let's land it.

Thanks! I hope it also works in WinCairo . . .
Comment 12 WebKit Commit Bot 2017-04-22 01:07:01 PDT
Comment on attachment 306812 [details]
Include win changes

Rejecting attachment 306812 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'build', '--no-clean', '--no-update', '--build-style=release', '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Last 500 characters of output:
eC /Volumes/Data/EWS/WebKit/WebKitBuild/DumpRenderTree.build/Release/ImageDiff.build/Objects-normal/x86_64/PlatformImage.o /Volumes/Data/EWS/WebKit/Tools/ImageDiff/PlatformImage.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
	CompileC /Volumes/Data/EWS/WebKit/WebKitBuild/DumpRenderTree.build/Release/ImageDiff.build/Objects-normal/x86_64/ImageDiff.o /Volumes/Data/EWS/WebKit/Tools/ImageDiff/ImageDiff.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)

Full output: http://webkit-queues.webkit.org/results/3582981
Comment 13 Carlos Garcia Campos 2017-04-22 01:26:57 PDT
(In reply to WebKit Commit Bot from comment #12)
> Comment on attachment 306812 [details]
> Include win changes
> 
> Rejecting attachment 306812 [details] from commit-queue.
> 
> Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch',
> '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'build',
> '--no-clean', '--no-update', '--build-style=release', '--port=mac']"
> exit_code: 2 cwd: /Volumes/Data/EWS/WebKit
> 
> Last 500 characters of output:
> eC
> /Volumes/Data/EWS/WebKit/WebKitBuild/DumpRenderTree.build/Release/ImageDiff.
> build/Objects-normal/x86_64/PlatformImage.o
> /Volumes/Data/EWS/WebKit/Tools/ImageDiff/PlatformImage.cpp normal x86_64 c++
> com.apple.compilers.llvm.clang.1_0.compiler
> 	CompileC
> /Volumes/Data/EWS/WebKit/WebKitBuild/DumpRenderTree.build/Release/ImageDiff.
> build/Objects-normal/x86_64/ImageDiff.o
> /Volumes/Data/EWS/WebKit/Tools/ImageDiff/ImageDiff.cpp normal x86_64 c++
> com.apple.compilers.llvm.clang.1_0.compiler
> (2 failures)
> 
> Full output: http://webkit-queues.webkit.org/results/3582981

#include <WebCore/PlatformExportMacros.h>
         ^
1 error generated.

I have no idea why this is failing to build now.
Comment 14 Carlos Garcia Campos 2017-04-26 23:49:05 PDT
(In reply to Carlos Garcia Campos from comment #13)
> (In reply to WebKit Commit Bot from comment #12)
> > Comment on attachment 306812 [details]
> > Include win changes
> > 
> > Rejecting attachment 306812 [details] from commit-queue.
> > 
> > Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch',
> > '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'build',
> > '--no-clean', '--no-update', '--build-style=release', '--port=mac']"
> > exit_code: 2 cwd: /Volumes/Data/EWS/WebKit
> > 
> > Last 500 characters of output:
> > eC
> > /Volumes/Data/EWS/WebKit/WebKitBuild/DumpRenderTree.build/Release/ImageDiff.
> > build/Objects-normal/x86_64/PlatformImage.o
> > /Volumes/Data/EWS/WebKit/Tools/ImageDiff/PlatformImage.cpp normal x86_64 c++
> > com.apple.compilers.llvm.clang.1_0.compiler
> > 	CompileC
> > /Volumes/Data/EWS/WebKit/WebKitBuild/DumpRenderTree.build/Release/ImageDiff.
> > build/Objects-normal/x86_64/ImageDiff.o
> > /Volumes/Data/EWS/WebKit/Tools/ImageDiff/ImageDiff.cpp normal x86_64 c++
> > com.apple.compilers.llvm.clang.1_0.compiler
> > (2 failures)
> > 
> > Full output: http://webkit-queues.webkit.org/results/3582981
> 
> #include <WebCore/PlatformExportMacros.h>
>          ^
> 1 error generated.
> 
> I have no idea why this is failing to build now.

Could someone help me with this? I don't know why this is failing now. It worked for me locally and in EWS, but now it's failing, and I don't know what have changed since then.
Comment 15 Alex Christensen 2017-04-27 11:07:47 PDT
It builds fine for me locally, and EWS liked it.  I'd say commit it and see what happens.  I'm not sure why the commit queue didn't like it.
Comment 16 Carlos Garcia Campos 2017-04-27 22:34:25 PDT
(In reply to Alex Christensen from comment #15)
> It builds fine for me locally, and EWS liked it.  I'd say commit it and see
> what happens.  I'm not sure why the commit queue didn't like it.

The thing is that I tried yesterday in a mac and got the same error than EWS.
Comment 17 Carlos Garcia Campos 2017-05-09 04:05:20 PDT
I'm trying to rebase this patch now that ImageDiff has been moved from DRT to its own project, but I don't see the ImageDiff now in Xcode to do the changes. Is there any magic I need to do in Xcode for the new project to show up?
Comment 18 Carlos Garcia Campos 2017-05-09 05:27:33 PDT
Manually adding a new group to WebKit.xcworkspace/contents.xcworkspacedata made it appear in XCode.
Comment 19 Carlos Garcia Campos 2017-05-09 06:36:34 PDT
Created attachment 309491 [details]
Rebased patch
Comment 20 Build Bot 2017-05-09 06:38:32 PDT
Attachment 309491 [details] did not pass style-queue:


ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:27:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:37:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 3 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 21 Build Bot 2017-05-09 08:43:25 PDT
Comment on attachment 309491 [details]
Rebased patch

Attachment 309491 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3705722

New failing tests:
compositing/absolute-inside-out-of-view-fixed.html
fast/forms/file/intrinsic-min-width-overrides-width.html
Comment 22 Build Bot 2017-05-09 08:43:27 PDT
Created attachment 309498 [details]
Archive of layout-test-results from ews122 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews122  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 23 Carlos Garcia Campos 2017-05-09 08:46:43 PDT
Created attachment 309500 [details]
Rebase again after r216504
Comment 24 Build Bot 2017-05-09 08:47:57 PDT
Attachment 309500 [details] did not pass style-queue:


ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:27:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:37:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 3 in 9 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 25 Carlos Garcia Campos 2017-05-09 09:06:21 PDT
Created attachment 309501 [details]
Try to fix win build
Comment 26 Build Bot 2017-05-09 09:09:38 PDT
Attachment 309501 [details] did not pass style-queue:


ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:27:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:37:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 3 in 10 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 27 Alex Christensen 2017-05-09 09:58:28 PDT
Comment on attachment 309491 [details]
Rebased patch

View in context: https://bugs.webkit.org/attachment.cgi?id=309491&action=review

r=me.  There's room for improvement, but this is an improvement because it unites the code from the different platforms.

> Tools/ImageDiff/cg/PlatformImageCG.cpp:116
> +PlatformImage::PlatformImage(CGImageRef image)
> +    : m_image(image)
> +{
> +}
> +
> +PlatformImage::~PlatformImage()
> +{
> +    CFRelease(m_image);
> +    free(m_buffer);
> +}

I think it would be nicer to have the constructor call CFRetain and have the callers properly release their images.  We shouldn't rely on the caller knowing that this object adopts it without any annotation.  I guess it's just a small tool that nobody looks at often, but it should still make sense.

> Tools/ImageDiff/cg/PlatformImageCG.cpp:145
> +    m_buffer = calloc(height, rowBytes);

It would be nice if we could use std::unique_ptr<uint8_t[]> or something so we could avoid all this manual memory management.  Just glancing at this makes it hard to tell if we should check m_buffer for something already there and free it if there is.
Comment 28 Carlos Garcia Campos 2017-05-09 10:06:58 PDT
(In reply to Alex Christensen from comment #27)
> Comment on attachment 309491 [details]
> Rebased patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=309491&action=review
> 
> r=me.  There's room for improvement, but this is an improvement because it
> unites the code from the different platforms.

Yes, I tried to keep existing code as mush as possible, just removing all the duplications.

> > Tools/ImageDiff/cg/PlatformImageCG.cpp:116
> > +PlatformImage::PlatformImage(CGImageRef image)
> > +    : m_image(image)
> > +{
> > +}
> > +
> > +PlatformImage::~PlatformImage()
> > +{
> > +    CFRelease(m_image);
> > +    free(m_buffer);
> > +}
> 
> I think it would be nicer to have the constructor call CFRetain and have the
> callers properly release their images.  We shouldn't rely on the caller
> knowing that this object adopts it without any annotation.  I guess it's
> just a small tool that nobody looks at often, but it should still make sense.

My previous patch used RetainPtr everywhere and the constructor received a &&, but then ImageDiff was made standalone and WTF dependency removed, so I had to go back to manually release everything as existing code does. Note that I'm not familiar with CG APIs.

> > Tools/ImageDiff/cg/PlatformImageCG.cpp:145
> > +    m_buffer = calloc(height, rowBytes);
> 
> It would be nice if we could use std::unique_ptr<uint8_t[]> or something so
> we could avoid all this manual memory management.  Just glancing at this
> makes it hard to tell if we should check m_buffer for something already
> there and free it if there is.

I agree, but again this is just moving existing code. We can add further improvements in follow up patches. I don't think we need to null check m_buffer since free is null safe and m_buffer is initialized to nullptr in the header.
Comment 29 Carlos Garcia Campos 2017-05-09 10:15:03 PDT
Created attachment 309510 [details]
Try to fix win build
Comment 30 Build Bot 2017-05-09 10:17:27 PDT
Attachment 309510 [details] did not pass style-queue:


ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:27:  Found header this file implements before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted.  [build/include_order] [4]
ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:36:  Alphabetical sorting problem.  [build/include_order] [4]
ERROR: Tools/ImageDiff/cg/PlatformImageCG.cpp:37:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 3 in 10 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 31 WebKit Commit Bot 2017-05-10 01:16:18 PDT
Comment on attachment 309510 [details]
Try to fix win build

Clearing flags on attachment: 309510

Committed r216576: <http://trac.webkit.org/changeset/216576>
Comment 32 WebKit Commit Bot 2017-05-10 01:16:20 PDT
All reviewed patches have been landed.  Closing bug.