One feature update to RAD Studio 10.4.2, driven by analysis showing an increase in the number of developers using remote desktop to development during Covid, has been a speed up to the IDE rendering over Remote Desktop.
The main issues focused on were the IDE freezing in some situations (such as when connecting or disconnecting remote desktop), flickering, and a few AV’s.
The QP items looked at for 10.4.2 include:
- Reconnect an Existing RDP session using the same screen settings (same machine) RS-99048
- Reconnect an Existing RDP session using different screen settings (e.g from a different machine) RS-103339
- Reconnect an Existing RDP session with the FMX designer opened causes AV.
Additionally, there were a number of internal reports.
While I’ve not got a sample project that can be shared, I have got permission to share a few notes the R&D team at Embarcadero provided based on their experiences, and I hope this will be useful to other developers too.
The root cause for all those issues is that any RDP session change (lock, unlock, connect, disconnect) sent a system-wide setting change (WM_SETTINGCHANGE) causing a message cascade that leads to multiple redraws in the IDE. This was the cause of some of the AV’s as between the cascade messages sent by the OS it included the WM_THEMECHANGED message that was triggering the handle recreation for some controls. This was affecting the VCL/FMX designers when they were left open and a session was reconnected via RDP.
The WTS API provides a way to receive the RDP session change notifications (WM_WTSSESSION_CHANGE). Managing this enables the IDE to become notified when the session is locked, unlocked, connected, disconnected, and from here we can choose how the WM_SETTINGCHANGE is handled and avoid the flickering/repainting issues.
One note from the R&D team was using VCL styles on terminal services is more likely to cause an application to see flicker under normal circumstances.
This skeleton sample of code (untested) should hopefully provide pointers in the right direction for anyone looking to add similar support into their applications.
[crayon-6762e36191201555791097/]