Virtual Desktop Published App - screen flickering, blackouts and crashing

%3CLINGO-SUB%20id%3D%22lingo-sub-2944536%22%20slang%3D%22en-US%22%3EVirtual%20Desktop%20Published%20App%20-%20screen%20flickering%2C%20blackouts%20and%20crashing%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2944536%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20in%20the%20process%20of%20moving%20our%20.NET%20ERP%20system%20to%20Azure.%20We%20will%20be%20running%20it%20as%20a%20virtual%20desktop%20published%20app.%20We%20have%20it%20working%20perfectly%20when%20you%20log%20into%20the%20session%20desktop%2C%20but%20when%20you%20try%20to%20run%20it%20as%20a%20published%20app%20we%20get%20a%20lot%20of%20flickering%2C%20temporary%20black%20screen%20and%20periodically%20complete%20app%20crashing.%20It%20seems%20the%20harder%20the%20app%20is%20working%20the%20worse%20the%20artifacts%20are.%3C%2FP%3E%3CP%3EWe%20really%20need%20this%20to%20work%20work.%20Are%20there%20any%20known%20fixes%20or%20best%20practices%20to%20get%20published%20apps%20to%20run%20smoothly%3F%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3EDave%20Cline%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2953249%22%20slang%3D%22en-US%22%3ERe%3A%20Virtual%20Desktop%20Published%20App%20-%20screen%20flickering%2C%20blackouts%20and%20crashing%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2953249%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1213141%22%20target%3D%22_blank%22%3E%40dcline97%3C%2FA%3E%26nbsp%3BDoes%20the%20ERP%20system%20happen%20to%20be%20SAP%3F%26nbsp%3B%20Those%20sound%20exactly%20like%20issues%20I%20had%20with%20SAP%20GUI%20years%20ago%20in%20a%20Terminal%20Services%20environment.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20so%2C%20you%20may%20want%20to%20look%20in%203%20places%20for%20lists%20of%20tweaks%20needed%20to%20keep%20SAP%20GUI%20as%20a%20published%20app%20from%20exhausting%20GDI%20handles%2C%20which%20is%20what%20it%20did%20back%20then%20without%20tweaks.%26nbsp%3B%20I%20haven't%20used%20SAP%20in%20a%20long%20while%2C%20so%20I%20can't%20say%20how%20much%20it's%20changed%20since%2C%20but%20worth%20looking%20into%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1)%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsupport.citrix.com%2Farticle%2FCTX127399%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsupport.citrix.com%2Farticle%2FCTX127399%3C%2FA%3E%3C%2FP%3E%3CP%3E(most%20important%20setting%20of%20these%20is%20setting%20the%20Classic%20or%20Enjoy%20theme%20instead%20of%20the%20Signature%20theme%2C%20but%20all%20apply)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E2)%20SAP%20Note%20200694%20-%20%22Notes%20on%20SAP%20GUI%20when%20used%20via%20terminal%20server.%22%26nbsp%3B%20SAP%20support%20notes%20are%20behind%20a%20support%20paywall%2C%20so%20I%20can't%20post%20the%20whole%20PDF%20%2Cbut%20the%20key%20takeaways%20were%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EHKEY_LOCAL_MACHINE%20-%26gt%3B%20Software%20-%26gt%3B%20Wow6432%20-%26gt%3B%20SAP%20-%26gt%3B%20General%20-%26gt%3B%3CBR%20%2F%3EAppearance%20-%26gt%3B%20Animation%20(REG_SZ)%26nbsp%3B%3D%20%22Off%22%20to%20disable%20the%20%22Server%20active%22%20animation%20in%20the%20upper%20right%20corner.%26nbsp%3B%3C%2FLI%3E%3CLI%3EDisable%20the%20picture%20in%20the%20%22Easy%20Access%22%20menu%20-%20this%20is%20done%20on%20the%20SAP%20backend%20configuration%20by%20adding%20entry%20%22HIDE_START_IMAGE%22%20%3D%20%22YES%22%20in%20the%20SSM_CUST%20table%3C%2FLI%3E%3CLI%3EHKEY_LOCAL_MACHINE%20-%26gt%3B%20Software%20-%26gt%3B%20Wow6432%20-%26gt%3B%20SAP%20-%26gt%3B%20General%20-%26gt%3B%3CBR%20%2F%3EAppearance%20-%26gt%3B%20ShowShadowBorder%20(REG_DWORD)%20%3D%200%20to%20disable%20the%20SAP%20%22Shadow%20Frame%22%20to%20save%20graphical%20resources%20in%20modern%20themes%2C%20OR%20use%20the%20Classic%20%2F%20Enjoy%20theme%20(which%20was%20what%20ended%20up%20working%20for%20my%20deployment)%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E3)%20SAP%20Note%20138869%20-%20%22SAP%20GUI%20on%20Windows%20Terminal%20Server%20(WTS)%22%26nbsp%3B%20Again%2C%20behind%20a%20paywall%2C%20but%20the%20one%20takeaways%20that%20isn't%20in%20%232%20is%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3EDisable%20SAP%20animations%20(SAP%20Logon%20-%26gt%3B%20Settings%20-%26gt%3B%20Extended%20Settings%20-%26gt%3B%20Low%20speed%20connection)%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAgain%2C%20the%20above%20only%20matters%20if%20you're%20using%20SAP%2C%20and%20SAP's%20desktop%20app%20may%20have%20changed%20to%20overcome%20these%2C%20but%20worth%20checking%20with%20SAP%20support%20to%20get%20the%20latest%20version%20of%20the%20equivalent%20documents%20to%20outline%20tweaks%20needed%20for%20SAP%20in%20Terminal%20Servers%2C%20if%20that's%20what%20you're%20using.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%3CSTRONG%3E%20not%3C%2FSTRONG%3E%20SAP%2C%20you%20may%20wish%20to%20look%20into%20troubleshooting%20GDI%20handle%20leaks%20using%20an%20app%20like%20Bear%20(%3CA%20href%3D%22https%3A%2F%2Fthe-sz.com%2Fproducts%2Fbear%2Findex.php%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fthe-sz.com%2Fproducts%2Fbear%2Findex.php%3C%2FA%3E).%26nbsp%3B%20Usually%2C%20in%20my%20experience%2C%20when%20an%20application%20has%20flickering%20that%20gets%20worse%20the%20harder%20it's%20working%2C%20the%20more%20instances%20there%20are%2C%20or%20the%20longer%20it's%20been%20running%2C%20that%20has%20been%20an%20issue%20with%20GDI%20handle%20exhaustion%20(which%20is%20what%20SAP%20was%20doing%20and%20the%20above%20settings%20fixed%20for%20that%20particular%20app).%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%20you%20seeing%20UI%20elements%20also%20show%20up%20in%20the%20wrong%20place%2C%20e.g.%20buttons%20out%20of%20place%20and%20such%3F%26nbsp%3B%20If%20so%2C%20that's%20a%20surefire%20sign%20you're%20dealing%20with%20GDI%20handle%20exhaustion%20(though%20it%20doesn't%20_always_%20happen%20when%20you're%20are%20the%20GDI%20handle%20cap%2C%20it's%20a%20pretty%20common%20occurrence%20in%20that%20situation).%26nbsp%3B%20In%20RDS%20(and%20therefore%20AVD)%2C%20a%20single%20process%20is%20limited%20to%2010%2C000%20GDI%20objects%2C%20and%20there%20are%2065%2C535%20total%20allowed%20per%20session.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20Bear%20seems%20to%20indicate%20you're%20coming%20close%20to%20the%2065535%20per%20session%20or%2010K%20per%20process%20limit%20when%20it's%20going%20wonky%2C%20then%20the%20fix%20options%20are%20going%20to%20be%20either%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1)%20Tweaking%20the%20app%20to%20disable%20any%20themes%20%2F%20animation%20%2F%20graphical%20effects%20(to%20try%20to%20reduce%20the%20number%20of%20elements%20drawn%20and%20therefore%20able%20to%20be%20leaked)%3C%2FP%3E%3CP%3E2)%20Getting%20the%20developer%20to%20fix%20their%20app%20to%20not%20have%20GDI%20handle%20leak%20bugs%3C%2FP%3E%3CP%3E3)%20Moving%20to%20publishing%20full%20Win10%20%2F%2011%20desktops%20with%20the%20app%20in%20them%2C%20instead%20of%20publishing%20the%20app%20(see%20below)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20dealt%20with%20a%20major%20clinical%20care%20app%20that%20had%20a%20GDI%20exhaustion%20issue%20the%20developer%20couldn't%20%2F%20wouldn't%20fix%2C%20and%20the%20only%20solution%2C%20once%20I%20was%20able%20to%20prove%20it%20was%20GDI%20handle%20exhaustion%2C%20was%20to%20use%20a%20full%20Windows%2010%20desktop%20to%20provide%20access%20to%20the%20app%2C%20with%20the%20session%20limits%20set%20to%201%20user%20per%20desktop%20(e.g.%20pooled%201%3A1).%26nbsp%3B%20This%20then%20allowed%20me%20to%20increase%20the%20number%20of%20GDI%20handles%20per%20app%20by%20changing%20the%20registry%20setting%20noted%20here%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Fsysinfo%2Fgdi-objects%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Fsysinfo%2Fgdi-objects%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20didn't%20necessarily%20_fix_%20the%20root%20problem%2C%20but%20it%20was%20a%20bandaid%20to%20let%20me%20let%20the%20(badly%20coded)%20app%20leak%20way%20more%20handles%20before%20going%20wonky%2C%20and%20only%20have%20one%20user%20on%20each%20box%20running%20it%2C%20so%20that%2C%20for%2099%25%20of%20users%2C%20they%20could%20get%20through%20an%208%20hour%20day%20before%20the%20app%20exhausted%20the%20handle%20limit%20with%20its%20leaks.%26nbsp%3B%20I%20then%20had%20the%20boxes%20setup%20to%20automatically%20reboot%20on%20user%20logoff%2C%20and%20had%20idle%20%2F%20disconnect%20timers%20setup%20to%20ensure%20the%20users%20were%20logged%20off%20every%20night%2C%20so%20that%20the%20leaks%20would%20be%20cleaned%20up%20on%20user%20logout%20via%20a%20reboot%2C%20to%20get%20the%20machines%20ready%20for%20the%20next%20day.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

We are in the process of moving our .NET ERP system to Azure. We will be running it as a virtual desktop published app. We have it working perfectly when you log into the session desktop, but when you try to run it as a published app we get a lot of flickering, temporary black screen and periodically complete app crashing. It seems the harder the app is working the worse the artifacts are.

We really need this to work work. Are there any known fixes or best practices to get published apps to run smoothly?

Thanks,

Dave Cline

1 Reply

@dcline97 Does the ERP system happen to be SAP?  Those sound exactly like issues I had with SAP GUI years ago in a Terminal Services environment. 

 

If so, you may want to look in 3 places for lists of tweaks needed to keep SAP GUI as a published app from exhausting GDI handles, which is what it did back then without tweaks.  I haven't used SAP in a long while, so I can't say how much it's changed since, but worth looking into:

 

1) https://support.citrix.com/article/CTX127399

(most important setting of these is setting the Classic or Enjoy theme instead of the Signature theme, but all apply.  I know the article says Citrix, but it's all still Terminal Services at the core as far as session / GDI handle memory management goes, which is what those fix.)

 

2) SAP Note 200694 - "Notes on SAP GUI when used via terminal server."  SAP support notes are behind a support paywall, so I can't post the whole PDF ,but the key takeaways were:

 

  • HKEY_LOCAL_MACHINE -> Software -> Wow6432 -> SAP -> General ->
    Appearance -> Animation (REG_SZ) = "Off" to disable the "Server active" animation in the upper right corner. 
  • Disable the picture in the "Easy Access" menu - this is done on the SAP backend configuration by adding entry "HIDE_START_IMAGE" = "YES" in the SSM_CUST table
  • HKEY_LOCAL_MACHINE -> Software -> Wow6432 -> SAP -> General ->
    Appearance -> ShowShadowBorder (REG_DWORD) = 0 to disable the SAP "Shadow Frame" to save graphical resources in modern themes, OR use the Classic / Enjoy theme (which was what ended up working for my deployment)

 

3) SAP Note 138869 - "SAP GUI on Windows Terminal Server (WTS)"  Again, behind a paywall, but the one takeaways that isn't in #2 is:

 

  • Disable SAP animations (SAP Logon -> Settings -> Extended Settings -> Low speed connection)

 

Again, the above only matters if you're using SAP, and SAP's desktop app may have changed to overcome these, but worth checking with SAP support to get the latest version of the equivalent documents to outline tweaks needed for SAP in Terminal Servers, if that's what you're using.

 

 

If not SAP, you may wish to look into troubleshooting GDI handle leaks using an app like Bear (https://the-sz.com/products/bear/index.php).  Usually, in my experience, when an application has flickering that gets worse the harder it's working, the more instances there are, or the longer it's been running, that has been an issue with GDI handle exhaustion (which is what SAP was doing and the above settings fixed for that particular app). 

 

Are you seeing UI elements also show up in the wrong place, e.g. buttons out of place and such?  If so, that's a surefire sign you're dealing with GDI handle exhaustion (though it doesn't _always_ happen when you're are the GDI handle cap, it's a pretty common occurrence in that situation).  In RDS (and therefore AVD), a single process is limited to 10,000 GDI objects, and there are 65,535 total allowed per session. 

 

If Bear seems to indicate you're coming close to the 65535 per session or 10K per process limit when it's going wonky, then the fix options are going to be either:

 

1) Tweaking the app to disable any themes / animation / graphical effects (to try to reduce the number of elements drawn and therefore able to be leaked)

2) Getting the developer to fix their app to not have GDI handle leak bugs

3) Moving to publishing full Win10 / 11 desktops with the app in them, instead of publishing the app (see below)

 

I've dealt with a major clinical care app that had a GDI exhaustion issue the developer couldn't / wouldn't fix, and the only solution, once I was able to prove it was GDI handle exhaustion, was to use a full Windows 10 desktop to provide access to the app, with the session limits set to 1 user per desktop (e.g. pooled 1:1).  This then allowed me to increase the number of GDI handles per app by changing the registry setting noted here: https://docs.microsoft.com/en-us/windows/win32/sysinfo/gdi-objects

 

It didn't necessarily _fix_ the root problem, but it was a bandaid to let me let the (badly coded) app leak way more handles before going wonky, and only have one user on each box running it, so that, for 99% of users, they could get through an 8 hour day before the app exhausted the handle limit with its leaks.  I then had the boxes setup to automatically reboot on user logoff, and had idle / disconnect timers setup to ensure the users were logged off every night, so that the leaks would be cleaned up on user logout via a reboot, to get the machines ready for the next day.