Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5efa773c authored by Jesse Hall's avatar Jesse Hall
Browse files

Revert "Load the gralloc module at library load"

This reverts commit 33c08a53. Some
gralloc implementations apparently have library initializers (executed
on dlopen) which create anonymous sockets, open device nodes, etc.
which Zygote and some other non-Zygote-child processes that use libui
don't have permissions to do. When the library initializer fails, it
crashes the process.

Reverting this until this initialization code can be made lazy (on
first use of gralloc).

Bug: 62732270
Test: boot fugu to launcher
parent 8dc55df1
Loading
Loading
Loading
Loading
+9 −20
Original line number Original line Diff line number Diff line
@@ -293,31 +293,20 @@ Return<void> GrallocMapper::unlock(void* buffer, unlock_cb hidl_cb) {
    return Void();
    return Void();
}
}


namespace {
IMapper* HIDL_FETCH_IMapper(const char* /* name */) {
// Load the gralloc module when this shared library is loaded, rather than
    const hw_module_t* module = nullptr;
// waiting until HIDL_FETCH_IMapper is called. This allows it (and its
// dependencies) to be loaded by Zygote, reducing app startup time and sharing
// pages dirtied during library load between all apps.
struct GrallocModule {
    const hw_module_t* module;
    GrallocModule() : module(nullptr) {
    int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
    int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
        ALOGE_IF(err, "failed to get gralloc module: %s (%d)", strerror(-err),
    if (err) {
                 err);
        ALOGE("failed to get gralloc module");
        return nullptr;
    }
    }
};
GrallocModule gGralloc;
}  // namespace

IMapper* HIDL_FETCH_IMapper(const char* /* name */) {
    if (!gGralloc.module) return nullptr;


    uint8_t major = (gGralloc.module->module_api_version >> 8) & 0xff;
    uint8_t major = (module->module_api_version >> 8) & 0xff;
    switch (major) {
    switch (major) {
        case 1:
        case 1:
            return new Gralloc1Mapper(gGralloc.module);
            return new Gralloc1Mapper(module);
        case 0:
        case 0:
            return new Gralloc0Mapper(gGralloc.module);
            return new Gralloc0Mapper(module);
        default:
        default:
            ALOGE("unknown gralloc module major version %d", major);
            ALOGE("unknown gralloc module major version %d", major);
            return nullptr;
            return nullptr;