RFR: 8313697: [XWayland][Screencast] consequent getPixelColor calls are slow [v3]

Sergey Bylokhov serb at openjdk.org
Mon Aug 14 20:28:10 UTC 2023


On Mon, 14 Aug 2023 14:12:59 GMT, Alexander Zvegintsev <azvegint at openjdk.org> wrote:

>> Right now, each call to getPixelColor/createScreenCapture opens and closes a ScreenCast session. 
>> When there are many such calls in a row, it becomes a rather time-consuming operation.
>> 
>> For example,
>> 
>> 
>> for (int i = 0; i < 50; i++) {
>>     for (int j = 0; j < 50; j++) {
>>         robot.getPixelColor(i, j);
>>     }
>> } 
>> 
>> `50x50 took 375219ms`
>> 
>> This fix offers optimization by keeping the session open and closing it only 2 seconds after the last activity.
>> 
>> `50x50 took 28113ms` which is ~ 13 times faster.
>> 
>> Testing looks good.
>
> Alexander Zvegintsev has updated the pull request incrementally with one additional commit since the last revision:
> 
>   fix app exit issue

src/java.desktop/unix/classes/sun/awt/screencast/ScreencastHelper.java line 127:

> 125:             @Override
> 126:             public void run() {
> 127:                 closeSession();

What happen if the "closeSession" is executed why the new Robot#getRGBPixels is called? In the robot code we call timerCloseSessionRestart to restart/cancel timer, but I think it could be possible that closeSession() is already executed and may close session right before it will be used by the robot but after we "open" it. 

Or this case is not possible?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15250#discussion_r1293936326


More information about the client-libs-dev mailing list