After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 429347 - Dogtail's utils.screenshot() not working properly on exported display
Dogtail's utils.screenshot() not working properly on exported display
Status: RESOLVED WONTFIX
Product: dogtail
Classification: Deprecated
Component: Framework
0.6.1
Other All
: Normal major
: ---
Assigned To: Dogtail Maintainers
Dogtail Maintainers
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2007-04-13 13:25 UTC by Alexander Todorov
Modified: 2011-02-07 06:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
shows that screenshot() works (747 bytes, application/x-compressed-tar)
2007-12-12 16:58 UTC, Alexander Todorov
Details

Description Alexander Todorov 2007-04-13 13:25:30 UTC
Please describe the problem:
When an application is running on the same host but is shown on another display using Dogtail's utils.screenshot() function produces pure black images.
However using other procedural API (e.g. click("Next")) is working fine.

Steps to reproduce:
1. Start a second GNOME session on the same machine.
2. $ export DISPLAY=:0   ## we are running at :1.0
3. $ python
Python 2.4.3 (#1, Dec 11 2006, 11:39:03) 
[GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from dogtail.utils import *
Creating logfile at /tmp/dogtail/logs/log_20070413-151513_debug ...
>>> screenshot()
GTK Accessibility Module initialized
Screenshot taken: /tmp/dogtail/screenshot_20070413-151517.png
'/tmp/dogtail/screenshot_20070413-151517.png'
>>> Ctrl+D
4. Open the image with EOG. It is black.

Actual results:
The produced screenshot is pure black color.

Expected results:
The produced screenshot must show the applications visible on user's desktop.

Does this happen every time?
yes

Other information:
Comment 1 Zack Cerza 2007-06-25 18:47:26 UTC
Sorry, I thought I had commented on this. I can't reproduce this problem...
Comment 2 Alexander Todorov 2007-06-26 09:55:30 UTC
I can reproduce the problem. Here is some information about packages versions:

dogtail-0.6.1-2.el5
gtk2-2.10.4-16.el5
pygtk2-2.10.1-8.el5

What other info do you need?

Can you make screenshots on exported display?
Comment 3 Alexander Todorov 2007-06-26 11:54:32 UTC
The above rpm versions are on RHEL 5

Below is on clean install on Fedora 7:
dogtail-0.6.1-1.fc7
pyspi-0.6.1-3.fc7
gtk2-2.10.13-1.fc7
pygtk2-2.10.4-2.fc7

Comment 4 Alexander Todorov 2007-12-12 14:07:36 UTC
(In reply to comment #1)
> Sorry, I thought I had commented on this. I can't reproduce this problem...
> 

1. Log in to your GNOME session. This is DISPLAY=:0
2. press Ctrl+alt+F1 to go to the text console
3. log in with your username (no root)
4. type: startx -- :1 (which start a second GNOME session here)
5. open gnome-terminal and type:
   $ export DISPLAY=:0   ## we are running at :1.0
   $ python
   >>> from dogtail.utils import screenshot()
   >>> screenshot()
   GTK Accessibility Module initialized
   Screenshot taken: /tmp/dogtail/screenshot_20070413-151517.png
   '/tmp/dogtail/screenshot_20070413-151517.png'
   >>> Ctrl+D
6. Now press Ctrl+Alt+F7 to return to the previous GNOME session (:0)
7. Open the image with EOG (or other image viewer).
8. Resulting image is black.

Additional info:
- it's not necessary to start a second GNOME session. You may skip step #4, the result is the same.

- I have a script starting Xvnc on :1 and a Dogtail script which succeeded in taking the screenshot. I will investigate further. 
Comment 5 Alexander Todorov 2007-12-12 16:58:24 UTC
Created attachment 100838 [details]
shows that screenshot() works

Steps to reproduce it working:
1) run Xvnc :1
2) export DISPLAY=:1
3) run some application
4) dogtail.utils.screenshot()
Comment 6 Zack Cerza 2007-12-12 17:36:11 UTC
OK, I'm not sure why I was unable to reproduce this before, but I can now. Here's the code in question:

    import gtk.gdk
    import gobject
    rootWindow = gtk.gdk.get_default_root_window()
    geometry = rootWindow.get_geometry()
    pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, geometry[2], \
            geometry[3])
    gtk.gdk.Pixbuf.get_from_drawable(pixbuf, rootWindow, \
            rootWindow.get_colormap(), 0, 0, 0, 0, geometry[2], geometry[3])
    # gtk.gdk.Pixbuf.save() needs 'jpeg' and not 'jpg'
    if fileExt == 'jpg': fileExt = 'jpeg'
    try: pixbuf.save(path, fileExt)
    except gobject.GError:
        raise ValueError, "Failed to save screenshot in %s format" % fileExt

It seems like since the root window has the correct dimensions (at least in my case), that everything would be fine. But for some reason gtk.gdk.Pixbuf.get_from_drawable() isn't doing anything - it's leaving the pixbuf blank.
Comment 7 Zack Cerza 2007-12-12 17:43:42 UTC
Ugh, I wonder if this is our problem:

http://www.moeraki.com/pygtkreference/pygtk2reference/class-gdkpixbuf.html#method-gdkpixbuf--get-from-drawable
"If src is a window, and the window is off the screen, then there is no image data in the obscured/offscreen regions to be placed in the pixbuf."
Comment 8 Michal Babej 2007-12-12 20:11:18 UTC
I think they are referring to window's coordinates off the screen, especially bottom right corner. I think this might be interesting too:

"The gtk.gdk.get_default_root_window() function returns 
the root gtk.gdk.Window (the parent window that all other windows 
are inside) for the default display and screen."
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^

But i might get it wrong.

-- mb
Comment 9 Zack Cerza 2007-12-12 20:35:12 UTC
What would the default be other than $DISPLAY?
Comment 10 Zack Cerza 2007-12-12 20:41:17 UTC
btw, when reproducing this I didn't even start a second session; I just used my already-running one.
Comment 11 Alexander Todorov 2007-12-13 10:13:35 UTC
(In reply to comment #10)
> btw, when reproducing this I didn't even start a second session; I just used my
> already-running one.
> 

So you skipped sstep #4 in comment #4, right?
Something interesting:
The working script in comment #5 has the following properties:
The process that starts X server (Xvnc) also exports display and runs the application and the Dogtail script. All sub-processes have the same parent.

In the non working reproducer X has already been started from init, and the Dogtail script is started from another terminal. I think they don't have the same parent.

Not sure if that helps or is relevant. I'm not a GTK guy so that's pretty much what I can do.
Comment 12 Fabio Durán Verdugo 2011-02-07 06:08:30 UTC
dogtail development has been stalled and it has been unmaintained for a few
years now.
Maintainers don't have future development plan so i am closing bugs as WONTFIX.
Please feel free to reopen the bugs in future if anyone takes the responsibility for active development.