#4104 closed defect (fixed)
Screenshot is all black in XO-4
Reported by: | godiard | Owned by: | erikos |
---|---|---|---|
Priority: | High | Milestone: | |
Component: | Sugar | Version: | Unspecified |
Severity: | Major | Keywords: | regression, r+, olpc-test-passed |
Cc: | humitos, erikos, dsd, godiard | Distribution/OS: | OLPC |
Bug Status: | Assigned |
Description
(And is not a rugby player)
TestCase:
Press Alt-1, go to the Journal and look at the screenshot created, you will see a black rectangle.
Tested in xo-4 and xo-1.75, the error only happens in xo-4.
Nothing in the log.
Other instances generate images like the preview associated to a activity, or the bookmarks in Browse or Read.
Is not solved installing pygobject3-3.3.91 (see #4102)
Attachments (4)
Change History (22)
comment:1 Changed 11 years ago by humitos
comment:2 Changed 11 years ago by tonyforster
see also Laptop12277
comment:3 Changed 11 years ago by humitos
- Cc humitos added
I've just tested this on XO-4 build 13.1.0 os11 and it worked (no more black image)
After a while I took another screenshot and it was the same. I took another and another and they were the same than the first one.
comment:4 Changed 11 years ago by manuq
I can confirm humitos comment, also with xo-4 build os11.
- take a screenshot, then go to the Journal, open it: all normal.
- navigate to another place in the Sugar UI, take another screenshot: is the same as the first one
All successive screenshots are the same.as the first one taken.
comment:5 Changed 11 years ago by manuq
- Keywords regression added
comment:6 Changed 11 years ago by manuq
- Distribution/OS changed from Unspecified to OLPC
Seems specific to XO-4, so reporting in olpc trac: http://dev.laptop.org/ticket/12314
comment:7 Changed 11 years ago by erikos
- Bug Status changed from Unconfirmed to Assigned
- Priority changed from Unspecified by Maintainer to High
- Severity changed from Unspecified to Major
http://dev.laptop.org/ticket/12314 has been closed as a dup of http://dev.laptop.org/ticket/12277
Changed 10 years ago by humitos
comment:8 Changed 10 years ago by humitos
- Cc erikos dsd godiard added
- Keywords r? added
I attached a patch that works property on XO-4, XO-1.75 and XO-1.5.
I'm not sure what is the exactly difference with the old code. Please, take a look at the commit message and if you know what it is, provide the explanation here. Thanks!
comment:9 Changed 10 years ago by godiard
I think the name of the varibles you are using is not clear.
window_surface = Gdk.Window.create_similar_surface(
window, cairo.CONTENT_COLOR, width, height)
should be:
screenshot_surface = Gdk.Window.create_similar_surface(
window, cairo.CONTENT_COLOR, width, height)
because that surface is not the real window surface, but the destination of the paint operation.
Other than that, I think is ok.
comment:10 follow-ups: ↓ 12 ↓ 14 Changed 10 years ago by humitos
comment:12 in reply to: ↑ 10 Changed 10 years ago by erikos
comment:13 Changed 10 years ago by godiard
erikos, new patch with a better header attached
comment:14 in reply to: ↑ 10 Changed 10 years ago by manuq
Replying to humitos:
The "issue" that I see with the old code is that we are passing a GdkWindow (link) to Gdk.cairo_create (link) instead of a Cairo Context.
No, in the current code we use gdk.cairo_create which receives a GdkWindow.
http://developer.gnome.org/gdk3/stable/gdk3-Cairo-Interaction.html#gdk-cairo-create
comment:15 Changed 10 years ago by manuq
I've found that the issue is the creation of the screenshot surface. Using gdk_window_create_similar_surface works because according to the documentation it creates a more compatible surface. And is the same we are using in the toolkit.
Current approach:
- create a cairo context for the root window (gdk_cairo_create) to get its target surface 'window_surface' (cairo_get_target),
- create a new surface with the same size as the window 'screenshot_surface' and format cairo.FORMAT_ARGB32 (cairo.ImageSurface)
- create a new cairo context with that new surface as target (cairo.Context)
- set 'window_surface' as the source of the new cairo context
- paint it (cairo_paint) and save it to a PNG file (cairo.Surface.write_to_png)
Browse approach:
- To create the new surface 'screenshot_surface' for step 2. above, use gdk_window_create_similar_surface instead. In toolkit (Activity.get_preview) we do the same. I think is better because according to the documentation it creates a more compatible surface.
- To set the window surface as the source surface on the new context, step 4. above, use gdk_cairo_set_source_window instead. In toolkit (Activity.get_preview) we use widget.draw(cr) directly which Ithink is a better approach when you have a widget, but we have a Gdk window instead.
comment:16 Changed 10 years ago by manuq
- Keywords olpc-test-pending added
- Resolution set to fixed
- Status changed from new to closed
Pushed 34fb1f8d .
comment:17 Changed 10 years ago by greenfeld
- Keywords olpc-test-passed added; olpc-test-pending removed
Screenshots work on all four current XO platforms in Sugar 0.98.2/OLPC 13.1.0 os20.
It does work on XO-1.5 too 13.1.0 os8