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

Commit 43bccf83 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Call Layer::getLayerDebugInfo from the main thread

Fixes an issue where drawing state could be accessed from a binder
thread. The function also mixed current state with drawing state
incorrectly. The function now only retrieves drawing state.

Bug: 150226608
Test: Steps in bug doesn't repro
Test: atest sffakehwc_test
Change-Id: I5537c53e8214e2785473839d71fd483d1a3219b6
parent 5bcc8f8a
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -691,8 +691,7 @@ public:
        return result;
        return result;
    }
    }


    virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const
    virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) {
    {
        if (!outLayers) {
        if (!outLayers) {
            return UNEXPECTED_NULL;
            return UNEXPECTED_NULL;
        }
        }
+1 −1
Original line number Original line Diff line number Diff line
@@ -354,7 +354,7 @@ public:
     *
     *
     * Requires the ACCESS_SURFACE_FLINGER permission.
     * Requires the ACCESS_SURFACE_FLINGER permission.
     */
     */
    virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const = 0;
    virtual status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) = 0;


    virtual status_t getColorManagement(bool* outGetColorManagement) const = 0;
    virtual status_t getColorManagement(bool* outGetColorManagement) const = 0;


+1 −1
Original line number Original line Diff line number Diff line
@@ -785,7 +785,7 @@ public:
        return NO_ERROR;
        return NO_ERROR;
    }
    }
    status_t injectVSync(nsecs_t /*when*/) override { return NO_ERROR; }
    status_t injectVSync(nsecs_t /*when*/) override { return NO_ERROR; }
    status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* /*layers*/) const override {
    status_t getLayerDebugInfo(std::vector<LayerDebugInfo>* /*layers*/) override {
        return NO_ERROR;
        return NO_ERROR;
    }
    }
    status_t getCompositionPreference(
    status_t getCompositionPreference(
+1 −1
Original line number Original line Diff line number Diff line
@@ -1501,7 +1501,7 @@ LayerDebugInfo Layer::getLayerDebugInfo(const DisplayDevice* display) const {
    LayerDebugInfo info;
    LayerDebugInfo info;
    const State& ds = getDrawingState();
    const State& ds = getDrawingState();
    info.mName = getName();
    info.mName = getName();
    sp<Layer> parent = getParent();
    sp<Layer> parent = mDrawingParent.promote();
    info.mParentName = parent ? parent->getName() : "none"s;
    info.mParentName = parent ? parent->getName() : "none"s;
    info.mType = getType();
    info.mType = getType();
    info.mTransparentRegion = ds.activeTransparentRegion_legacy;
    info.mTransparentRegion = ds.activeTransparentRegion_legacy;
+7 −10
Original line number Original line Diff line number Diff line
@@ -1449,17 +1449,14 @@ status_t SurfaceFlinger::injectVSync(nsecs_t when) {
    return mScheduler->injectVSync(when, calculateExpectedPresentTime(when)) ? NO_ERROR : BAD_VALUE;
    return mScheduler->injectVSync(when, calculateExpectedPresentTime(when)) ? NO_ERROR : BAD_VALUE;
}
}


status_t SurfaceFlinger::getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) const {
status_t SurfaceFlinger::getLayerDebugInfo(std::vector<LayerDebugInfo>* outLayers) {
    TimedLock lock(mStateLock, s2ns(1), __FUNCTION__);
    if (!lock.locked()) {
        return TIMED_OUT;
    }

    const auto display = getDefaultDisplayDeviceLocked();
    outLayers->clear();
    outLayers->clear();
    mCurrentState.traverseInZOrder(
    schedule([=] {
            [&](Layer* layer) { outLayers->push_back(layer->getLayerDebugInfo(display.get())); });
        const auto display = ON_MAIN_THREAD(getDefaultDisplayDeviceLocked());

        mDrawingState.traverseInZOrder([&](Layer* layer) {
            outLayers->push_back(layer->getLayerDebugInfo(display.get()));
        });
    }).wait();
    return NO_ERROR;
    return NO_ERROR;
}
}


Loading