Bug 549210 - [Regression][Cocoa] GC.drawImage draws transparent region into black once getImageData is invoked
Summary: [Regression][Cocoa] GC.drawImage draws transparent region into black once get...
Status: CLOSED DUPLICATE of bug 310387
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.12   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 4.14   Edit
Assignee: Sravan Kumar Lakkimsetti CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted, regression
: 549780 (view as bug list)
Depends on:
Blocks: 551605
  Show dependency tree
 
Reported: 2019-07-12 05:32 EDT by Kent Xu CLA
Modified: 2019-11-10 16:21 EST (History)
8 users (show)

See Also:


Attachments
code (938 bytes, application/octet-stream)
2019-07-12 05:32 EDT, Kent Xu CLA
no flags Details
png (11.27 KB, image/png)
2019-07-12 05:33 EDT, Kent Xu CLA
no flags Details
screenshot of problem seen in eclipse (21.40 KB, image/png)
2019-07-17 06:29 EDT, Lakshmi P Shanmugam CLA
no flags Details
Image of problem (84.21 KB, image/jpeg)
2019-10-16 09:24 EDT, David Garratt CLA
no flags Details
Results of test - see image attached. (158.20 KB, image/jpeg)
2019-10-17 12:06 EDT, David Garratt CLA
no flags Details
Additional screen dump (291.64 KB, image/jpeg)
2019-10-17 12:22 EDT, David Garratt CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kent Xu CLA 2019-07-12 05:32:22 EDT
Created attachment 279259 [details]
code

The input file is a png with transparent background. The transparent area turns into black if I invoke getImageData on the image first. 

I am running on OSX in Dark Theme, Eclipse 2019-06. The problem is not found in 2019-03.
Comment 1 Kent Xu CLA 2019-07-12 05:33:55 EDT
Created attachment 279260 [details]
png
Comment 2 Andrey Loskutov CLA 2019-07-12 05:37:40 EDT
Is this a regression in 4.12?
Comment 3 Kent Xu CLA 2019-07-12 05:49:57 EDT
 It only happens in 4.12 not in 4.11 or earlier versions. In my example, I am invoking getImageData() before the paint. In reality, I am calling getImageData in a much later time. The problem shows up on the next repaint, whenever that is.
Comment 4 Lakshmi P Shanmugam CLA 2019-07-15 04:27:05 EDT
Sravan, can you please investigate?
Comment 5 Sravan Kumar Lakkimsetti CLA 2019-07-15 05:29:10 EDT
I don't have access to Mac today. I will look into this tomorrow
Comment 6 Sravan Kumar Lakkimsetti CLA 2019-07-16 06:27:32 EDT
This is a regression in 4.12. I have a fair idea on where the problem could be. I will work towards fixing the problem
Comment 7 Lakshmi P Shanmugam CLA 2019-07-17 06:29:29 EDT
Created attachment 279307 [details]
screenshot of problem seen in eclipse

I also see this in the Eclipse IDE.
Comment 8 Sravan Kumar Lakkimsetti CLA 2019-07-18 00:40:11 EDT
The problem is this file https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT/cocoa/org/eclipse/swt/internal/graphics/ImageUtil.java

Here we create a new image rep for required size but this code is not able to handle images with alpha/transparency. This is resulting in black colour where it should have been transparent.

@Till,
Can you please suggest how we can improve this method to handle alpha?
Comment 9 Till Brychcy CLA 2019-07-18 15:16:55 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #8)
> @Till,
> Can you please suggest how we can improve this method to handle alpha?

Create a rep with hasAlpha=true (and samplesPerPixel=4) if any of the existing reps has alpha.

It looks like NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat doesn't work (at least on macOS 10.14) with hasAlpha=true, so I'd try with a value of 0 instead.
Comment 10 Sravan Kumar Lakkimsetti CLA 2019-07-19 00:46:24 EDT
(In reply to Till Brychcy from comment #9)
> (In reply to Sravan Kumar Lakkimsetti from comment #8)
> > @Till,
> > Can you please suggest how we can improve this method to handle alpha?
> 
> Create a rep with hasAlpha=true (and samplesPerPixel=4) if any of the
> existing reps has alpha.
> 
> It looks like NSAlphaFirstBitmapFormat |
> OS.NSAlphaNonpremultipliedBitmapFormat doesn't work (at least on macOS
> 10.14) with hasAlpha=true, so I'd try with a value of 0 instead.

Thanks Till. It worked. I will put in a patch shortly
Comment 11 Eclipse Genie CLA 2019-07-19 00:59:07 EDT
New Gerrit change created: https://git.eclipse.org/r/146338
Comment 13 Sravan Kumar Lakkimsetti CLA 2019-07-19 06:40:14 EDT
(In reply to Eclipse Genie from comment #12)
> Gerrit change https://git.eclipse.org/r/146338 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=94e3dd2e453b92538d63a927db1cf02005f959e8

This partially fixes the problem. There is still problem in the image copy and this can be seen in this example https://bugs.eclipse.org/bugs/attachment.cgi?id=195741 from bug 310387
Comment 14 Sravan Kumar Lakkimsetti CLA 2019-08-23 04:33:35 EDT
(In reply to Eclipse Genie from comment #12)
> Gerrit change https://git.eclipse.org/r/146338 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=94e3dd2e453b92538d63a927db1cf02005f959e8

The problem described here has been fixed by the above commit.
Comment 15 Lakshmi P Shanmugam CLA 2019-08-26 06:43:50 EDT
*** Bug 549780 has been marked as a duplicate of this bug. ***
Comment 16 Wim Jongman CLA 2019-10-11 03:54:11 EDT
It looks like this bug is still not fixed in 2019-09. Please see details in this report.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=551605
Comment 17 Sravan Kumar Lakkimsetti CLA 2019-10-16 01:10:05 EDT
(In reply to Wim Jongman from comment #16)
> It looks like this bug is still not fixed in 2019-09. Please see details in
> this report.
> 
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=551605
This problem is more related to bug 310387. Is it possible for you test the patch attached to Bug 310387?

Thanks
Sravan
Comment 18 David Garratt CLA 2019-10-16 03:38:56 EDT
Could someone provide some instructions on what I need to do in order to download and apply this patch.

I'm running MacOs Mojave and Eclipse 2019 09

Sorry - not done any kind of patching on Eclipse before

Dave
Comment 19 Sravan Kumar Lakkimsetti CLA 2019-10-16 06:04:46 EDT
(In reply to Dave Garratt from comment #18)
> Could someone provide some instructions on what I need to do in order to
> download and apply this patch.
> 
> I'm running MacOs Mojave and Eclipse 2019 09
> 
> Sorry - not done any kind of patching on Eclipse before
> 
> Dave

Created a new SDK build with the path. It can be downloaded from here I (In reply to Dave Garratt from comment #18)
> Could someone provide some instructions on what I need to do in order to
> download and apply this patch.
> 
> I'm running MacOs Mojave and Eclipse 2019 09
> 
> Sorry - not done any kind of patching on Eclipse before
> 
> Dave

I will try to create a new SDK build for you test. We are having trouble in our build infrastructure today. Hopefully by tomorrow I will be able to create build for you
Comment 20 Wim Jongman CLA 2019-10-16 06:55:52 EDT
(In reply to Dave Garratt from comment #18)
> Could someone provide some instructions on what I need to do in order to
> download and apply this patch.
> 
> I'm running MacOs Mojave and Eclipse 2019 09
> 
> Sorry - not done any kind of patching on Eclipse before
> 
> Dave

Dave, a patch was submitted today. Tomorrow there should be a new "I"-build available here [1]. It starts with I2019...

Download that version, install WB into it and see if that fixes it. You can also download the one from yesterday and see if that fixes things.


[1] https://download.eclipse.org/eclipse/downloads/
Comment 21 David Garratt CLA 2019-10-16 09:24:58 EDT
Created attachment 280278 [details]
Image of problem

I have downloaded and tested last nights version. Some improvements to the components on the palette but some issues remain.

I have attached an image.

I will have a look at todays update later when it appears on the website,

Dave
Comment 22 Sravan Kumar Lakkimsetti CLA 2019-10-17 02:21:16 EDT
Fix is included in https://download.eclipse.org/eclipse/downloads/drops4/I20191016-1800/. Could please verify this build?

Also please report if you see any issues in the colors used in the platform
Comment 23 David Garratt CLA 2019-10-17 12:06:23 EDT
Created attachment 280304 [details]
Results of test - see image attached.

I can see what's changed :-) Better than black but perhaps not what you were aiming for.
Comment 24 David Garratt CLA 2019-10-17 12:22:13 EDT
Created attachment 280305 [details]
Additional screen dump
Comment 25 Wim Jongman CLA 2019-10-17 15:23:54 EDT
(In reply to Dave Garratt from comment #24)
> Created attachment 280305 [details]
> Additional screen dump

Thanks for sticking with us Dave.
Comment 26 Sravan Kumar Lakkimsetti CLA 2019-10-18 00:59:37 EDT
This problem appears only in 10.14 and above. Apple changed the behavior around transparency in 10.14. This problem got uncovered when I did the hidpi support.

I will continue my investigation and (if you don't mind) provide updates in bug 310387 as that bug describes the problem more appropriately
Comment 27 David Garratt CLA 2019-10-18 05:09:47 EDT
Is it helpful or relevant that Eclipse 2019 03 with Window Builder Pro does not have the problem.
Comment 28 Wim Jongman CLA 2019-11-10 16:21:01 EST

*** This bug has been marked as a duplicate of bug 310387 ***