Community
Participate
Working Groups
Created attachment 287362 [details] stripped-down example code We are working on an OSS integration of a chromium-based browser in Eclipse. The current prototype works by just copying the image rendered by an Electron browser into an SWT Canvas. Works fine on Windows and Linux but is very slow on Mac with retina display (not if no retina display is connected). I have attached a stripped-down example that just copies images with random color to an SWT Canvas. This example runs with ~40 frames per second on my Windows machine and with ~3 FPS on an iMac with retina display. With an external monitor it runs much faster also on the iMac. Is there a way how I can improve this? Am I doing something wrong? Help from the SWT experts out there would be very much appreciated.
I tested this on MacBook Pro (Retina), macOS 12.3.1, Java Temurin-11.0.13+8 I also get around 3-4 FPS, but around 90 FPS on Mac M1 with non-Retina display. But I don't think it's specifically the Canvas class, as I get the same results with Composite or just painting to the Shell.
> but around 90 FPS on Mac M1 with non-Retina display. That should be 60 FPS
> But I don't think it's specifically the Canvas class, as I get the same > results with Composite or just painting to the Shell. Good finding! I guess, I could have stripped down the example even further. Thanks for retesting!
Leif, it may not even be due to Mac and Retina display. It could just be due to the amount of pixels. Retina displays obviously have x4 more pixels. Changing the values of the following line higher or lower will show this: Point size = new Point(1500, 1000);
I aggree that the problem here is certainly caused by the 4x more pixels. I am not a Mac expert but I think there should be a way to paint a 1500x1000 square e.g. black at same speed as this is done under Windows. In my opinion the upscaling should be done by the GPU. At least I hope so.
Are you testing on Windows with hi-res display?
The biggest screen I have here is 2560x1440px. Of course, if I enlarge the Canvas, the framerate drops here as well (~19 FPS @ 2500x1400). But I guess a fixed size of 1500x1000px should have same speed on retina and non-retina displays regardless on how the presentation is done internally. Or would you say since it is 3000x2000px internally on retina this can not work faster?
I tried this on MacBookPro in both Retina and non-Retina mode and observe the same behavior - frame rate decreases as the resolution increases - in both modes. Most of the time is taken by the GC.drawImage() calls, but we only call the native NSImage.drawInRect() and do nothing specific to retina. Need to investigate further if performance can be improved here.
Any news on this? Leif, can you provide more details and/or insights to push this forward? Or is there anything specific that is blocking this?
(In reply to Martin Lippert from comment #9) > Any news on this? Leif, can you provide more details and/or insights to push > this forward? Or is there anything specific that is blocking this? As noted before, the difference is coming from the native API itself - NSImage.drawInRect() [1]. Could find any options to tweak the performance for retina display. @Alex, do you have any ideas on how to improve the performance of NSImage.drawInRect() for retina? [1] - https://developer.apple.com/documentation/appkit/nsimage/1520067-drawinrect
Unfortunately I don't have a retina display for debugging.
(In reply to Alexandr Miloslavskiy from comment #11) > Unfortunately I don't have a retina display for debugging. Where are you located?