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

Commit ee768c2d authored by Courtney Goeltzenleuchter's avatar Courtney Goeltzenleuchter
Browse files

Clean up featuresutils library

dlclose the featureutils library when closing the driver.
Had tried closing inside load_angle but that won't work
due to threading and we will have a featureutil resource
we want to keep around.

Bug: 118613436
Bug: 118375731
Test: monkey UI testing
Test: cts-tradefed run singleCommand cts -m CtsAngleIntegrationHostTestCases

Change-Id: I40b13c679665951935f0e7254f24c384645365f3
parent 0a33671e
Loading
Loading
Loading
Loading
+20 −15
Original line number Original line Diff line number Diff line
@@ -275,10 +275,24 @@ void* Loader::open(egl_connection_t* cnx)
    return (void*)hnd;
    return (void*)hnd;
}
}


void Loader::close(void* driver)
void Loader::close(egl_connection_t* cnx)
{
{
    driver_t* hnd = (driver_t*)driver;
    driver_t* hnd = (driver_t*) cnx->dso;
    delete hnd;
    delete hnd;
    cnx->dso = nullptr;

    if (cnx->featureSo) {
        dlclose(cnx->featureSo);
        cnx->featureSo = nullptr;
    }

    cnx->angleDecided = false;
    cnx->useAngle = false;

    if (cnx->vendorEGL) {
        dlclose(cnx->vendorEGL);
        cnx->vendorEGL = nullptr;
    }
}
}


void Loader::init_api(void* dso,
void Loader::init_api(void* dso,
@@ -553,15 +567,9 @@ static void* load_angle(const char* kind, android_namespace_t* ns, egl_connectio
        property_get("ro.product.manufacturer", manufacturer, "UNSET");
        property_get("ro.product.manufacturer", manufacturer, "UNSET");
        property_get("ro.product.model", model, "UNSET");
        property_get("ro.product.model", model, "UNSET");


        // Check if ANGLE is enabled. Workaround for b/118375731
        cnx->featureSo = load_angle_from_namespace("feature_support", ns);
        // We suspect that loading & unloading a library somehow corrupts
        if (cnx->featureSo) {
        // the process.
            ALOGV("loaded ANGLE's opt-in/out logic from namespace");
        property_get("debug.angle.enable", prop, "0");
        if (atoi(prop)) {
            so = load_angle_from_namespace("feature_support", ns);
        }
        if (so) {
            ALOGV("Temporarily loaded ANGLE's opt-in/out logic from namespace");
            bool use_version0_API = false;
            bool use_version0_API = false;
            bool use_version1_API = false;
            bool use_version1_API = false;
            fpANGLEGetUtilityAPI ANGLEGetUtilityAPI =
            fpANGLEGetUtilityAPI ANGLEGetUtilityAPI =
@@ -605,14 +613,11 @@ static void* load_angle(const char* kind, android_namespace_t* ns, egl_connectio
                    ALOGW("Cannot find ANGLEUseForApplication in library");
                    ALOGW("Cannot find ANGLEUseForApplication in library");
                }
                }
            }
            }
            ALOGV("Close temporarily-loaded ANGLE opt-in/out logic");
            dlclose(so);
            so = nullptr;
        } else {
        } else {
            // We weren't able to load and call the updateable opt-in/out logic.
            // We weren't able to load and call the updateable opt-in/out logic.
            // If we can't load the library, there is no ANGLE available.
            // If we can't load the library, there is no ANGLE available.
            use_angle = false;
            use_angle = false;
            ALOGV("Could not temporarily-load the ANGLE opt-in/out logic, cannot use ANGLE.");
            ALOGV("Could not load the ANGLE opt-in/out logic, cannot use ANGLE.");
        }
        }
        cnx->angleDecided = true;
        cnx->angleDecided = true;
    }
    }
+1 −1
Original line number Original line Diff line number Diff line
@@ -51,7 +51,7 @@ public:
    ~Loader();
    ~Loader();


    void* open(egl_connection_t* cnx);
    void* open(egl_connection_t* cnx);
    void close(void* driver);
    void close(egl_connection_t* cnx);


private:
private:
    Loader();
    Loader();
+1 −2
Original line number Original line Diff line number Diff line
@@ -275,8 +275,7 @@ EGLDisplay egl_display_t::getPlatformDisplay(EGLNativeDisplayType display,


        disp.dpy = dpy;
        disp.dpy = dpy;
        if (dpy == EGL_NO_DISPLAY) {
        if (dpy == EGL_NO_DISPLAY) {
            loader.close(cnx->dso);
            loader.close(cnx);
            cnx->dso = nullptr;
        }
        }
    }
    }


+1 −0
Original line number Original line Diff line number Diff line
@@ -80,6 +80,7 @@ struct egl_connection_t {
    bool                useAngle;
    bool                useAngle;
    EGLint              angleBackend;
    EGLint              angleBackend;
    void*               vendorEGL;
    void*               vendorEGL;
    void*               featureSo;
};
};
// clang-format on
// clang-format on