Mir

Merge lp:~mir-team/mir/fix-1475571 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2767
Proposed branch: lp:~mir-team/mir/fix-1475571
Merge into: lp:mir
Diff against target: 53 lines (+14/-16)
2 files modified
src/platforms/mesa/server/common/buffer_allocator.cpp (+0/-6)
tests/unit-tests/graphics/mesa/common/test_buffer_allocator.cpp (+14/-10)
To merge this branch: bzr merge lp:~mir-team/mir/fix-1475571
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Chris Halse Rogers Needs Fixing
Daniel van Vugt Approve
Review via email: mp+265224@code.launchpad.net

This proposal supersedes a proposal from 2015-07-17.

Commit message

Don't throw when gbm_device_is_format_supported returns false. We might have given it the scanout flag spuriously thanks to our weak heuristic, making it report false incorrectly. (LP: #1475571)

But rather than fixing the bo_flags, we can drop the whole call. Just use the existing error checking on the gbm_bo_create() call instead.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

That check is correct and should probably not be deleted.

I suspect the issue is now we're more careful with pixel format semantics, an invalid format used screencast is being detected. This could be a simple matter of accidentally requesting RGBA for an RGBX framebuffer or mixed up byte ordering. I'm somewhat confident the bug lies in mirscreencast but have not looked yet. Will do so today...

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Oh I see. It's probably the bo_flags getting GBM_BO_USE_SCANOUT due to the size of the surface (which is a very ugly heuristic). With the SCANOUT flag, gbm will refuse RGBA and only allow RGBX. That's spurious because we actually have no desire for scan-out support in screencasting and there might be a real alpha channel that we want.

I think if gbm_bo_create throws adequate errors still then this change is fine. Providing it passes CI.

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

An alternate fix could be to change:
  gbm_device_is_format_supported(device, gbm_format, bo_flags)
to:
  gbm_device_is_format_supported(device, gbm_format, 0)

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Note the lack of a replacement regression test. That's because one already exists (out of view of the diff):

TEST_F(MesaBufferAllocatorTest, throws_on_buffer_creation_failure)

Revision history for this message
Daniel van Vugt (vanvugt) :
review: Approve
Revision history for this message
Chris Halse Rogers (raof) wrote : Posted in a previous version of this proposal

If it really is the GBM_BO_USE_SCANOUT flag making the difference, then wouldn't it be a better idea to fix the allocator to not try to allocate a scanout buffer for screencasts (which doesn't make sense anyway).

I'd be concerned that just dropping the check will instead bite us later when we try and scanout from a BO that's not scanout-capable.

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Chris: We never had that check before. I only introduced it last week so dropping it loses nothing. And the logic it replaced was even worse.

If buffer creation is going to fail, let it fail. We check for that already and should never have been trying to predict if it will fail before it does.

Revision history for this message
Chris Halse Rogers (raof) wrote :

Yeah, fair enough. If gbm_bo_create doesn't return a scanoutable buffer when asked to provide one that's probably a gbm bug.

26 +TEST_F(MesaBufferAllocatorTest, is_format_supported_not_called)
should just be removed. We don't need to test that we don't call a function. It's a duplicate of the throws_on_buffer_creation_failure test a couple of tests up.

If you really want to test something, test that buffer allocation succeeds even if gbm_device_is_format_supported returns false. I don't think that's particularly necessary, though.

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

26 +TEST_F(MesaBufferAllocatorTest, is_format_supported_not_called)

The test name doesn't reflect a useful intent. I'm open argument that the test is useful for other reasons - with an appropriate name.

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

That's just a grammatical naming ambiguity (which isn't ambiguous after you look at the test). It actually means:
   gbm_device_is_format_supported__is_not_called

But that was too long to fit on one line, IIRC.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

OK

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Given the last change made was exactly what Chris requested, I'll take that as final approval.

Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/mesa/server/common/buffer_allocator.cpp'
2--- src/platforms/mesa/server/common/buffer_allocator.cpp 2015-07-16 07:03:19 +0000
3+++ src/platforms/mesa/server/common/buffer_allocator.cpp 2015-07-21 04:11:41 +0000
4@@ -157,12 +157,6 @@
5 bo_flags |= GBM_BO_USE_SCANOUT;
6 }
7
8- if (!gbm_device_is_format_supported(device, gbm_format, bo_flags))
9- {
10- BOOST_THROW_EXCEPTION(
11- std::runtime_error("Trying to create GBM buffer with unsupported pixel format"));
12- }
13-
14 gbm_bo *bo_raw = gbm_bo_create(
15 device,
16 buffer_properties.size.width.as_uint32_t(),
17
18=== modified file 'tests/unit-tests/graphics/mesa/common/test_buffer_allocator.cpp'
19--- tests/unit-tests/graphics/mesa/common/test_buffer_allocator.cpp 2015-07-16 07:03:19 +0000
20+++ tests/unit-tests/graphics/mesa/common/test_buffer_allocator.cpp 2015-07-21 04:11:41 +0000
21@@ -271,18 +271,22 @@
22 EXPECT_EQ(mir_pixel_format_argb_8888, supported_pixel_formats[0]);
23 }
24
25-TEST_F(MesaBufferAllocatorTest, alloc_with_unsupported_pixel_format_throws)
26-{
27+TEST_F(MesaBufferAllocatorTest, screencast_can_create_buffer)
28+{ // Regression test for LP: #1475571
29 using namespace testing;
30
31- /* We shouldn't try to create a buffer with an unsupported format */
32- EXPECT_CALL(mock_gbm, gbm_bo_create(_,_,_,_,_)).Times(0);
33- EXPECT_CALL(mock_gbm, gbm_device_is_format_supported(_,_,_))
34- .WillOnce(Return(0));
35-
36- EXPECT_THROW({
37- allocator->alloc_buffer(mg::BufferProperties{size, mir_pixel_format_abgr_8888, usage});
38- }, std::runtime_error);
39+ // Not expected to be called any more, but if it is...
40+ ON_CALL(mock_gbm, gbm_device_is_format_supported(_,_,GBM_BO_USE_SCANOUT))
41+ .WillByDefault(Return(0));
42+
43+ EXPECT_CALL(mock_gbm, gbm_bo_create(_,_,_,_,_));
44+
45+ EXPECT_NO_THROW({
46+ allocator->alloc_buffer(
47+ mg::BufferProperties{{1920,1080},
48+ mir_pixel_format_abgr_8888,
49+ mg::BufferUsage::hardware});
50+ });
51 }
52
53 MATCHER_P(GbmImportMatch, value, "import data matches")

Subscribers

People subscribed via source and target branches