black screenshots

moden.py's Avatar

moden.py

16 Nov, 2015 06:04 PM

Hi,
I faced with a problem all my screenshots almost black(see an example in the attachments). We run UI tests for pywinauto lib, the tests fails time to time. I've added screenshot creation on failure and collection them into the artifacts.
The problem is all the screenshots almost black, only one small visible piece of the expected image.
I've tried different approaches:
- via PIL (ImageGrab.grab())
- pyscreenshot.grab()
- win32 (hwindc = win32gui.GetWindowDC(hwin)
    # srcdc = win32ui.CreateDCFromHandle(hwindc))
All have the same result - black images.

In the other project (also on AppVeyor) a was able to get useful screenshots using PIL.
Please, point me to the solution.

PS. I tried RDP, but could not connect - 104.197.110.30:3389

Thanks in advance
Denis M.

  1. Support Staff 1 Posted by Feodor Fitsner on 16 Nov, 2015 06:12 PM

    Feodor Fitsner's Avatar

    I've just fixed RDP script to correctly identify port on those VMs. Please try to RDP again.

    What's the URL of other project?

  2. 2 Posted by moden.py on 16 Nov, 2015 07:07 PM

    moden.py's Avatar

    Works fine for - https://github.com/pywinauto/SWAPY
    Black screenshots for - https://github.com/pywinauto/pywinauto

    There are some difference in appveyor.yml. I tried use latest Pillow version and disable os: - Windows Server 2012 section. Unfortunately it did not help.

    Thanks for the RDP, trying...

  3. Support Staff 3 Posted by Feodor Fitsner on 16 Nov, 2015 08:53 PM

    Feodor Fitsner's Avatar

    What's AppVeyor project URL for this repo: https://github.com/pywinauto/SWAPY ?

  4. 4 Posted by moden.py on 17 Nov, 2015 06:47 AM

    moden.py's Avatar

    https://ci.appveyor.com/project/moden-py/swapy-pwvh2
    It is my fork. The last build has good screenshots in the artifact.

  5. Support Staff 5 Posted by Feodor Fitsner on 17 Nov, 2015 07:48 PM

    Feodor Fitsner's Avatar

    The account has been moved to a new environment - there might be some differences.
    Can you run swapy build once again to generate screenshots?

  6. 6 Posted by moden.py on 17 Nov, 2015 08:55 PM

    moden.py's Avatar

    Feodor, many thanks. The black screenshot now in SWAPY. ;-)
    https://ci.appveyor.com/project/moden-py/swapy-pwvh2/build/1.0.134
    Suppose, for testing, you have switched the environment like for pywinauto.

  7. Support Staff 7 Posted by Feodor Fitsner on 17 Nov, 2015 09:29 PM

    Feodor Fitsner's Avatar

    Well, actually this is the only environment we are going to have for OSS from now :-)
    But what's the difference? Does it expect some drivers or what? Have you tried looking via RDP?

  8. 8 Posted by moden.py on 18 Nov, 2015 05:02 PM

    moden.py's Avatar

    I suppose something has changed in the new environment. For example, Desktop Window Manager (DWM) some functions has been changed in Windows 8.1 it may cause the problem in Windows Server 2012 R2 we using.
    RDP works fine. More, the problem does not affect when I connect a RDP session.
    It seems like some driver sees that there is nobody to draw a picture. )))
    Please, take a look at the attachment, maybe it is a clue. I've not seen that table while was connecting by RDP.

  9. 9 Posted by moden.py on 18 Nov, 2015 07:04 PM

    moden.py's Avatar
  10. Support Staff 10 Posted by Feodor Fitsner on 18 Nov, 2015 07:20 PM

    Feodor Fitsner's Avatar

    That attachment looks OK to me - this is, actually, what you should see when logged in via RDP.

  11. 11 Posted by rami.abughazale... on 26 Nov, 2015 04:36 AM

    rami.abughazaleh's Avatar

    I'm experiencing similar behavior when running CodedUI tests.
    It works only if I connect to RDP before the tests are run.
    Most of the CodedUI tests fail if I don't connect to RDP and the screen is just black.

    This wasn't happening a month ago.

    I'm wondering if there are some power configuration settings, display settings, or screen saver settings that need to be turned off.

  12. 12 Posted by rami.abughazale... on 26 Nov, 2015 08:38 AM

    rami.abughazaleh's Avatar

    Here is an example log file that contains a screenshot:
    https://ci.appveyor.com/api/buildjobs/fvqvyklag2w4a11p/artifacts/a2838df1-316d-4c1c-b38c-1c091a3241da_UITestActionLog.html

    Notice it is all black, no wallpaper, taskbar, desktop icons, etc.

  13. 13 Posted by rami.abughazale... on 26 Nov, 2015 06:19 PM

    rami.abughazaleh's Avatar

    Here is an example log file that contains what I expected screenshots to look like:
    https://ci.appveyor.com/api/buildjobs/jfaaa3dtequwi4ah/artifacts/80d4a023-7495-4a95-92e8-78d1229aca3c_UITestActionLog.html
    That test was run and log created while logged into the build server using RDP.

  14. Support Staff 14 Posted by Feodor Fitsner on 02 Dec, 2015 01:12 AM

    Feodor Fitsner's Avatar

    Hi guys,

    If you are willing to help with solving "black screenshots" problem on OSS environment I have a deal for you! :)

    Whoever solves this problem first will get a free one-year subscription to AppVeyor Pro plan ($590 value).

    Please drop me a message if you'd like to participate.

    Your help is really appreciated!

  15. 15 Posted by rami.abughazale... on 02 Dec, 2015 01:31 AM

    rami.abughazaleh's Avatar

    Hi Feodor, I'm willing to try to resolve this issue.

    Are there any additional debugging tricks/access I can use to help resolve this issue?

    Thank you.

  16. Support Staff 16 Posted by Feodor Fitsner on 02 Dec, 2015 01:34 AM

    Feodor Fitsner's Avatar

    Great, thank you for willing to help with that!

    I've moved your account to Pro environment. Now, without operating system selected builds will be run on Pro environment and to run on OSS environment select, say, "Visual Studio 2013" OS image.

    These are instructions on how to access build workers via RDP: http://www.appveyor.com/docs/how-to/rdp-to-build-worker

    Let me know if you have any questions.

  17. 17 Posted by rami.abughazale... on 02 Dec, 2015 05:39 AM

    rami.abughazaleh's Avatar

    Thank you.

    After some investigation, it seems the issue may be related to file integrity levels.

    In my case, it is specifically on the TestResults directory, where the tests files are, within the clone directory.

    Previously, to circumvent the "Open File - Security Warning" dialog that appears (and requires user input) when launching exe files from within the TestResults directory, I had to run the following before the tests are run:
    icacls TestResults /setintegritylevel (CI)(OI)Low

    But for some reason, now I have to run the following:
    icacls TestResults /setintegritylevel (CI)(OI)Medium

    For reference, the "Open File - Security Warning" dialog can also be circumvented on a larger scope by launching Internet Explorer > Tools > Internet Options > Security > Internet > Custom level... > Launching applications and unsafe files > Enabled (not secure).

    However, now when opening HTML files within the TestResults directory, I get the "Internet Explorer restricted this webpage from running scripts or ActiveX controls." warning message which was not happening previously, when the file integrity level was set to Low, and the HTML files had the appropriate "Mark-of-the-Web" (MOTW), <!-- saved from url=(0016)http://localhost -->

    Thank you.

  18. 18 Posted by rami.abughazale... on 03 Dec, 2015 08:06 AM

    rami.abughazaleh's Avatar

    Has anyone else encountered this issue?
    Can this issue still be reproduced?
    Which project can I fork and test with to reproduce the issue?

    Thank you.

  19. 19 Posted by moden.py on 03 Dec, 2015 09:51 AM

    moden.py's Avatar

    Hi Rami,
    I am still see the problem.
    Here is today's try - https://ci.appveyor.com/project/moden-py/swapy-pwvh2/build/1.0.138

    You may try to fork from https://github.com/moden-py/SWAPY/tree/dev
    Commit d6f6baf102eac217e6b1497e2b1b8d4d12c0344d generates the black screenshots.

    Thanks

  20. 20 Posted by rami.abughazale... on 03 Dec, 2015 08:06 PM

    rami.abughazaleh's Avatar

    Thank you, moden.py, I had to explicitly set the build to use the Operating System labeled "Visual Studio 2013" in order to reproduce the issue.

    When the build was set to use "Windows Server 2012 R2" or "Visual Studio 2015", I was not able to reproduce it.

    Also, trying to set the build to use "Previous Visual Studio 2013" will also cause black screenshots.

  21. Support Staff 21 Posted by Feodor Fitsner on 04 Dec, 2015 01:32 AM

    Feodor Fitsner's Avatar

    Hey guys,

    Looks like I've got something! Take a look at these build results: https://ci.appveyor.com/project/FeodorFitsner/swapy/build/1.0.4

    In short, to make UI tests work add this line to your appveyor.yml install section:

    install:
    - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-desktop.ps1'))
    

    The script downloads FreeRDP client and connects via RDP to localhost thus creating a new RDP session. All build commands following this line will be running in that RDP session.

    I'm not yet completely sure how that works, but it works :) Maybe the approach could be further improved/optimized as, for instance, active RDP client adds some CPU overhead to the build worker.

    Anyway, give it a try for your builds and let me know how it worked. I'm going to document it.

    Btw, there is a "bonus" - you can set desired screen size like that:

    - ps: $screen_resolution = '1280x800'; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-desktop.ps1'))
    
  22. 22 Posted by moden.py on 05 Dec, 2015 01:54 PM

    moden.py's Avatar

    Hi Feodor,
    It does work for me!
    Thank you very much.
    Indeed, it seems like some optimization disables desktop drawing when nobody attached to the desktop.
    The possible slowdown is not a problem (at least now :-)))), so I am marking the issue as FIXED.

  23. Support Staff 23 Posted by Feodor Fitsner on 05 Dec, 2015 04:57 PM

    Feodor Fitsner's Avatar

    Great, thanks for the update!

    - Feodor

  24. 24 Posted by rami.abughazale... on 05 Dec, 2015 09:23 PM

    rami.abughazaleh's Avatar

    Thank you.

    I found this related issue / feature request:
    https://code.google.com/p/google-compute-engine/issues/detail?id=184

  25. 25 Posted by rami.abughazale... on 21 Dec, 2015 06:45 AM

    rami.abughazaleh's Avatar

    Unfortunately, I'm still having issues even when using FreeRDP and it seems to be directly related to the keyboard.

    For example, sometimes a call to Keyboard.SendKeys would cause my coded ui tests to fail unless I'm actually connected using Microsoft's RDP implementation.

  26. Support Staff 26 Posted by Feodor Fitsner on 21 Dec, 2015 09:25 PM

    Feodor Fitsner's Avatar

    Can you provide a sample of such test?

  27. 27 Posted by rami.abughazale... on 22 Dec, 2015 07:33 AM

    rami.abughazaleh's Avatar

    See the failed tests here:
    https://ci.appveyor.com/project/icnocop/cuite-cdb3i/build/tests

    The corresponding github project is here:
    https://github.com/icnocop/cuite/tree/specs

    Thank you.

  28. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:03 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac