Mir

Merge lp:~kdub/mir/fix-1158564 into lp:~mir-team/mir/trunk

Proposed by Kevin DuBois
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 537
Proposed branch: lp:~kdub/mir/fix-1158564
Merge into: lp:~mir-team/mir/trunk
Diff against target: 106 lines (+18/-27)
2 files modified
tests/draw/android_graphics.cpp (+1/-0)
tests/integration-tests/client/test_client_render.cpp (+17/-27)
To merge this branch: bzr merge lp:~kdub/mir/fix-1158564
Reviewer Review Type Date Requested Status
Alexandros Frantzis (community) Approve
Alan Griffiths Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+155380@code.launchpad.net

Commit message

fixes lp:1158564 (integration test failure)

(test bug caused destruction to go out-of-order, and some fields for the software buffers were not filled out correctly)

these did not cause issue with the sgx/nvidia drivers, but did with the adreno ones

Description of the change

fixes lp:1158564 (integration test failure)

(test bug caused destruction to go out-of-order, and some fields for the software buffers were not filled out correctly)

these did not cause issue with the sgx/nvidia drivers, but did with the adreno ones

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

after this, all nex4 tests pass :)

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

53 + std::shared_ptr<struct alloc_device_t> alloc_device;
54 std::shared_ptr<mga::AndroidBuffer> android_buffer;
55 std::shared_ptr<mga::AndroidBuffer> second_android_buffer;

Yikes. If you're having that issue, what I would suggest doing would be either:

a) Add a comment saying that this needs to be the order and hope it stays up-to-date
b) Wrap it all up into a new class, e.g:

class DrawTestAndroidBuffers
{
    public:

        // We require std::shared_ptr<struct alloc_device_t as a construction parameter to signify that the relevant mga::AndroidBuffers require it to be around during their lifetime.
        DrawTestAndroidBuffers (std::shared_ptr<struct alloc_device_t const&) { ... }

 std::shared_ptr<mga::AndroidBuffer> android_buffer;
 std::shared_ptr<mga::AndroidBuffer> second_android_buffer;
};

class DrawTestAndroidDevice
{
    public:

        std::shared_ptr<struct alloc_device_t> alloc_device;
        DrawTestAndroidBuffers android_buffers;
};

What that does is ensure that in order to initialize the android_buffers, you have to have an alloc_device first. The dependency is certainly implicit, but at least any future maintainer will think twice before changing it, and it makes it more difficult to accidentally change the order.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> 53 + std::shared_ptr<struct alloc_device_t> alloc_device;
> 54 std::shared_ptr<mga::AndroidBuffer> android_buffer;
> 55 std::shared_ptr<mga::AndroidBuffer> second_android_buffer;
>
> Yikes. If you're having that issue, what I would suggest doing would be
> either:
>
> a) Add a comment saying that this needs to be the order and hope it stays up-
> to-date
> b) Wrap it all up into a new class, e.g:

I prefer (if nothing is blocking it in this particular case):

c) Make it so that destruction order doesn't matter. If all components that need an alloc_device_t hold a shared_ptr to it, then it will be destroyed at the right time, i.e., when no one needs it anymore.

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

It isn't clear to me how all of the changes contribute to the solution.

/1/ Using "t->common.close((hw_device_t*)t)" in place of "gralloc_close(alloc_device.get())" for destruction.

/2/ Using make_shared() in place of fake_shared() to make destruction implicit instead of explicit.

/3/ Moving the shared_ptr member variable.

review: Needs Information
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

> > 53 + std::shared_ptr<struct alloc_device_t> alloc_device;
> > 54 std::shared_ptr<mga::AndroidBuffer> android_buffer;
> > 55 std::shared_ptr<mga::AndroidBuffer> second_android_buffer;
> >
> > Yikes. If you're having that issue, what I would suggest doing would be
> > either:
> >
> > a) Add a comment saying that this needs to be the order and hope it stays
> up-
> > to-date
> > b) Wrap it all up into a new class, e.g:
>
> I prefer (if nothing is blocking it in this particular case):
>
> c) Make it so that destruction order doesn't matter. If all components that
> need an alloc_device_t hold a shared_ptr to it, then it will be destroyed at
> the right time, i.e., when no one needs it anymore.

This is also a good solution too as it doesn't seem like there would be an ownership cycle between both the buffers and the allocator here.

Originally I had quickly cast my mind to the case of relying on some implicit side-effect of alloc_device_t being open, and then not being able to have alloc_device_t own the buffers, but that was wrong.

Kevin, please disregard my earlier comment.

Revision history for this message
Kevin DuBois (kdub) wrote :

Based on the comments, I changed this to integrate more parts from mga::, namely, AndroidBufferAllocator to take care of allocation. This removes the construction/destruction order dependency and makes the test cleaner

Also, this test is need of some cleanup, I think the bug is addressed well enough by these changes; there are still things that could be cleaned up in this test that are best done in later cleanups.

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

21 #include "src/server/frontend/protobuf_socket_communicator.h"
22 #include "mir/frontend/resource_cache.h"
26 #include "src/server/graphics/android/android_alloc_adaptor.h"
... perhaps more?

Unused headers (some of them were not being used even before the changes in this branch).

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

> 21 #include "src/server/frontend/protobuf_socket_communicator.h"
> 22 #include "mir/frontend/resource_cache.h"
> 26 #include "src/server/graphics/android/android_alloc_adaptor.h"
> ... perhaps more?
>
> Unused headers (some of them were not being used even before the changes in
> this branch).

Agreed. But this looks much clearer.

review: Needs Fixing
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 :

LGTM

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Loosk good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/draw/android_graphics.cpp'
2--- tests/draw/android_graphics.cpp 2013-02-01 19:25:41 +0000
3+++ tests/draw/android_graphics.cpp 2013-03-27 15:12:20 +0000
4@@ -103,6 +103,7 @@
5 {
6 native_handle_t* handle;
7 handle = (native_handle_t*) malloc(sizeof(int) * ( 3 + package->ipc_data.size() + package->ipc_fds.size() ));
8+ handle->version = sizeof(native_handle_t);
9 handle->numInts = package->ipc_data.size();
10 handle->numFds = package->ipc_fds.size();
11 int i;
12
13=== modified file 'tests/integration-tests/client/test_client_render.cpp'
14--- tests/integration-tests/client/test_client_render.cpp 2013-03-22 10:34:16 +0000
15+++ tests/integration-tests/client/test_client_render.cpp 2013-03-27 15:12:20 +0000
16@@ -18,31 +18,28 @@
17
18 #include "mir_test_framework/process.h"
19
20-#include "mir_toolkit/mir_client_library.h"
21-
22 #include "mir/compositor/buffer_ipc_package.h"
23-#include "src/server/frontend/protobuf_socket_communicator.h"
24-#include "mir/frontend/resource_cache.h"
25+#include "mir/compositor/buffer_properties.h"
26+#include "mir/graphics/buffer_initializer.h"
27 #include "src/server/graphics/android/android_buffer.h"
28-#include "src/server/graphics/android/android_alloc_adaptor.h"
29+#include "src/server/graphics/android/android_buffer_allocator.h"
30
31 #include "mir_test/draw/android_graphics.h"
32 #include "mir_test/draw/patterns.h"
33 #include "mir_test/stub_server_tool.h"
34 #include "mir_test/test_protobuf_server.h"
35-#include "mir_test/fake_shared.h"
36
37 #include <gmock/gmock.h>
38-
39 #include <thread>
40+#include <hardware/gralloc.h>
41 #include <GLES2/gl2.h>
42-#include <hardware/gralloc.h>
43
44 namespace mtf = mir_test_framework;
45 namespace mt=mir::test;
46 namespace mtd=mir::test::draw;
47 namespace mc=mir::compositor;
48 namespace mga=mir::graphics::android;
49+namespace mg=mir::graphics;
50 namespace geom=mir::geometry;
51
52 namespace
53@@ -443,21 +440,13 @@
54 size = geom::Size{geom::Width{test_width}, geom::Height{test_height}};
55 pf = geom::PixelFormat::abgr_8888;
56
57- /* allocate an android buffer */
58- int err;
59- const hw_module_t *hw_module;
60- struct alloc_device_t *alloc_device_raw;
61- err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hw_module);
62- if (err < 0)
63- throw std::runtime_error("Could not open hardware module");
64- gralloc_open(hw_module, &alloc_device_raw);
65- alloc_device = mt::fake_shared(*alloc_device_raw);
66- auto alloc_adaptor = std::make_shared<mga::AndroidAllocAdaptor>(alloc_device);
67- buffer_converter = std::make_shared<mtd::TestGrallocMapper>(hw_module, alloc_device.get());
68-
69-
70- android_buffer = std::make_shared<mga::AndroidBuffer>(alloc_adaptor, size, pf);
71- second_android_buffer = std::make_shared<mga::AndroidBuffer>(alloc_adaptor, size, pf);
72+ auto initializer = std::make_shared<mg::NullBufferInitializer>();
73+ allocator = std::make_shared<mga::AndroidBufferAllocator> (initializer);
74+ mc::BufferProperties properties(size, pf, mc::BufferUsage::hardware);
75+ android_buffer = allocator->alloc_buffer(properties);
76+ second_android_buffer = allocator->alloc_buffer(properties);
77+
78+ buffer_converter = std::make_shared<mtd::TestGrallocMapper>();
79
80 package = android_buffer->get_ipc_package();
81 second_package = second_android_buffer->get_ipc_package();
82@@ -471,7 +460,6 @@
83 void TearDown()
84 {
85 test_server.reset();
86- gralloc_close(alloc_device.get());
87 }
88
89 mir::protobuf::Connection response;
90@@ -485,11 +473,13 @@
91 mc::BufferID id2;
92 std::shared_ptr<mtd::TestGrallocMapper> buffer_converter;
93 std::shared_ptr<mtf::Process> client_process;
94+
95 std::shared_ptr<mc::BufferIPCPackage> package;
96 std::shared_ptr<mc::BufferIPCPackage> second_package;
97- std::shared_ptr<mga::AndroidBuffer> android_buffer;
98- std::shared_ptr<mga::AndroidBuffer> second_android_buffer;
99- std::shared_ptr<struct alloc_device_t> alloc_device;
100+
101+ std::shared_ptr<mc::Buffer> android_buffer;
102+ std::shared_ptr<mc::Buffer> second_android_buffer;
103+ std::shared_ptr<mga::AndroidBufferAllocator> allocator;
104
105 static std::shared_ptr<mtf::Process> render_single_client_process;
106 static std::shared_ptr<mtf::Process> render_double_client_process;

Subscribers

People subscribed via source and target branches