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

Commit 347691f8 authored by Stan Iliev's avatar Stan Iliev
Browse files

Fix a crash in skia pipeline, when empty reorder block is first

Fix a crash in skia pipeline, which happens if an empty reorder
barrier is inserted at index 0 in a SkiaDisplayList.
Add a unit test that repro the bug (unit test is crashing wihtout
the fix and passing with the fix).

Test: built and ran skia pipeline with angler-eng and run HWUI unit
tests.

Change-Id: I4aded15021c70cc0ae8daa83bbe8ed0e10a41eef
parent 4f8a7a55
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ void StartReorderBarrierDrawable::onDraw(SkCanvas* canvas) {
        //mChildren is allocated and initialized only the first time onDraw is called and cached for
        //subsequent calls
        mChildren.reserve(mEndChildIndex - mBeginChildIndex + 1);
        for (unsigned int i = mBeginChildIndex; i <= mEndChildIndex; i++) {
        for (int i = mBeginChildIndex; i <= mEndChildIndex; i++) {
            mChildren.push_back(const_cast<RenderNodeDrawable*>(&mDisplayList->mChildNodes[i]));
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -47,8 +47,8 @@ protected:
    virtual void onDraw(SkCanvas* canvas) override;

private:
    size_t mEndChildIndex;
    size_t mBeginChildIndex;
    int mEndChildIndex;
    int mBeginChildIndex;
    FatVector<RenderNodeDrawable*, 16> mChildren;
    SkiaDisplayList* mDisplayList;

+2 −0
Original line number Diff line number Diff line
@@ -1530,6 +1530,8 @@ public:
RENDERTHREAD_TEST(FrameBuilder, zReorder) {
    auto parent = TestUtils::createNode<RecordingCanvas>(0, 0, 100, 100,
            [](RenderProperties& props, RecordingCanvas& canvas) {
        canvas.insertReorderBarrier(true);
        canvas.insertReorderBarrier(false);
        drawOrderedNode(&canvas, 0, 10.0f); // in reorder=false at this point, so played inorder
        drawOrderedRect(&canvas, 1);
        canvas.insertReorderBarrier(true);
+2 −0
Original line number Diff line number Diff line
@@ -102,6 +102,8 @@ TEST(RenderNodeDrawable, zReorder) {

    auto parent = TestUtils::createSkiaNode(0, 0, 100, 100,
            [](RenderProperties& props, SkiaRecordingCanvas& canvas) {
        canvas.insertReorderBarrier(true);
        canvas.insertReorderBarrier(false);
        drawOrderedNode(&canvas, 0, 10.0f); // in reorder=false at this point, so played inorder
        drawOrderedRect(&canvas, 1);
        canvas.insertReorderBarrier(true);