-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Log platform selection #3212
base: main
Are you sure you want to change the base?
Log platform selection #3212
Conversation
0af4664
to
98ad96b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also a legacy CStrFree
hidden in existing code
namespace mir | ||
{ | ||
using CStr = std::unique_ptr<char[], CStringFree>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks like a recipe for an ODR violation - thanks to the anon namespace CStringFree
is a different type in each translation unit and that makes the mir::CStr
definition different in each TU.
#include <cstdlib> | ||
#include <memory> | ||
|
||
namespace | ||
{ | ||
class CStringFree | ||
{ | ||
public: | ||
void operator()(char* str) | ||
{ | ||
if(str) | ||
{ | ||
free(str); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
namespace mir | ||
{ | ||
using CStr = std::unique_ptr<char[], CStringFree>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- what? No header guards?
- The null check is redundant
- The
operator()
can beconst
- This doesn't handle
const
c_strings
#include <cstdlib> | |
#include <memory> | |
namespace | |
{ | |
class CStringFree | |
{ | |
public: | |
void operator()(char* str) | |
{ | |
if(str) | |
{ | |
free(str); | |
} | |
} | |
}; | |
} | |
namespace mir | |
{ | |
using CStr = std::unique_ptr<char[], CStringFree>; | |
} | |
#ifndef MIR_OWNING_C_STR_ | |
#define MIR_OWNING_C_STR_ | |
#include <cstdlib> | |
#include <memory> | |
namespace mir | |
{ | |
using CStr = std::unique_ptr<char[], decltype([](char const* p) { ::free(const_cast<char *>(p)); })>; | |
} | |
#endif |
rendering_platforms.reserve(rendering_platform_map.size()); | ||
|
||
// We want to make the egl-generic platform the last resort | ||
// So don't push it into rendering_platforms until the rest are done | ||
std::shared_ptr<graphics::RenderingPlatform> egl_generic; | ||
|
||
for (auto const& rp : rendering_platform_map) | ||
{ | ||
if (rp.first != "mir:egl-generic") | ||
{ | ||
rendering_platforms.push_back(rp.second); | ||
} | ||
else | ||
{ | ||
egl_generic = rp.second; | ||
} | ||
} | ||
|
||
// If we skipped egl-generic, add it to the end | ||
if (egl_generic) | ||
{ | ||
rendering_platforms.push_back(egl_generic); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this code is ugly, but why are we dropping it?
The commit comment "FIXME: Ooops! Don't throw away most of our hardware platforms!" doesn't reflect the change. (It just makes the order non-deterministic.)
@@ -311,6 +312,13 @@ auto mgg::DisplaySink::gbm_device() const -> std::shared_ptr<struct gbm_device> | |||
return gbm; | |||
} | |||
|
|||
auto mgg::DisplaySink::describe_output() const -> std::string | |||
{ | |||
std::unique_ptr<char[], void(*)(char*)> drm_node{drmGetDeviceNameFromFd2(drm_fd()), [](char* to_free) { free(to_free); }}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another incantation for CStr
This reverts commit 7a918eb.
Can confirm this brings Pi's performance back to what's expected. @freefos this is work-in-progress, but could you confirm with |
I'm struggling to know what changed to make that happen. Apart from logging, the change to |
Here's @RAOF's explanation from Matrix:
Yes, it needs a better solution (and bringing back the determinism), but this PR, so far, just confirmed the issue. With both 2.15 and this PR, MotionMark in WPE detects 60fps with Frame at ~15% CPU, compared to 2.16.2 detecting 15fps at 50-60% CPU usage of Frame. The logging from this branch provides:
|
Oh! We load multiple instances of each platform? I hadn't understood that. Easy to fix. (Incoming...) |
#include <memory> | ||
namespace mir | ||
{ | ||
using CStr = std::unique_ptr<char[], decltype([](char const* p) { ::free(const_cast<char *>(p)); })>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh. You learn something new every day. decltype(<lambda literal>)
is a neat way of getting a type with a specific operator()
!
@Saviq I can confirm this fixes the fps issue. |
@Saviq With this release wpe-webkit-mir-kiosk restarts once in a while. |
@Saviq Its again the issue where the memory usage increases until it crashes. |
Some logging, so I can get a snap on the Pi.