Hi Guys,
We recently updated Skia version from M83 to M91 and we are noticing memory corruption while using SkRunTimeEffect.
Have some
one seen this failure already?? Or any pointers how to debug this?
/SkiaRoot/src/gpu/GrBlockAllocator.h:610: fatal error:
"assert(block->fSentinel == kAssignedMarker)"
Below is
the call stack and sample code for SkRunTimeEffect.
Compiler
used ->Clang
Platform
-> emulator x86 API 23 and 29 (Test on both)
Call Stack:
sk_abort_no_print() SkMemory_malloc.cpp:49
GrBlockAllocator::Block* GrBlockAllocator::owningBlock<8u, 0u>(void const*, int)::'lambda'()::operator()() const GrBlockAllocator.h:610
GrBlockAllocator::Block* GrBlockAllocator::owningBlock<8u, 0u>(void const*, int) GrBlockAllocator.h:610
GrMemoryPool::release(void*) GrMemoryPool.cpp:112
SkSL::Pool::FreeMemory(void*) SkSLPool.cpp:107
SkSL::Poolable::operator delete(void*) SkSLPool.h:68
SkSL::Nop::~Nop() SkSLNop.h:19
std::__ndk1::default_delete<SkSL::Statement>::operator()(SkSL::Statement*) const memory:2338
std::__ndk1::unique_ptr<SkSL::Statement, std::__ndk1::default_delete<SkSL::Statement> >::reset(SkSL::Statement*) memory:2593
std::__ndk1::unique_ptr<SkSL::Statement, std::__ndk1::default_delete<SkSL::Statement> >::~unique_ptr() memory:2547
SkTArray<std::__ndk1::unique_ptr<SkSL::Statement, std::__ndk1::default_delete<SkSL::Statement> >, false>::~SkTArray() SkTArray.h:124
SkSTArray<2, std::__ndk1::unique_ptr<SkSL::Statement, std::__ndk1::default_delete<SkSL::Statement> >, false>::~SkSTArray() SkTArray.h:596
SkSL::Block::~Block() SkSLBlock.h:19
SkSL::Block::~Block() SkSLBlock.h:19
std::__ndk1::default_delete<SkSL::Statement>::operator()(SkSL::Statement*) const memory:2338
std::__ndk1::unique_ptr<SkSL::Statement, std::__ndk1::default_delete<SkSL::Statement> >::reset(SkSL::Statement*) memory:2593
std::__ndk1::unique_ptr<SkSL::Statement, std::__ndk1::default_delete<SkSL::Statement> >::~unique_ptr() memory:2547
SkSL::FunctionDefinition::~FunctionDefinition() SkSLFunctionDefinition.h:22
SkSL::FunctionDefinition::~FunctionDefinition() SkSLFunctionDefinition.h:22
std::__ndk1::default_delete<SkSL::ProgramElement>::operator()(SkSL::ProgramElement*) const memory:2338
std::__ndk1::unique_ptr<SkSL::ProgramElement, std::__ndk1::default_delete<SkSL::ProgramElement> >::reset(SkSL::ProgramElement*) memory:2593
std::__ndk1::unique_ptr<SkSL::ProgramElement, std::__ndk1::default_delete<SkSL::ProgramElement> >::~unique_ptr() memory:2547
std::__ndk1::allocator<std::__ndk1::unique_ptr<SkSL::ProgramElement, std::__ndk1::default_delete<SkSL::ProgramElement> > >::destroy(std::__ndk1::unique_ptr<SkSL::ProgramElement, std::__ndk1::default_delete<SkSL::ProgramElement> >*) memory:1880
void std::__ndk1::allocator_traits<std::__ndk1::allocator<std::__ndk1::unique_ptr<SkSL::ProgramElement, std::__ndk1::default_delete<SkSL::ProgramElement> > > >::__destroy<std::__ndk1::unique_ptr<SkSL::ProgramElement, std::__ndk1::default_delete<SkSL::ProgramElement> > >(std::__ndk1::integral_constant<bool, true>, std::__ndk1::allocator<std::__ndk1::unique_ptr<SkSL::ProgramElement, std::__ndk1::default_delete<SkSL::ProgramElement> > >&, std::__ndk1::unique_ptr<SkSL::ProgramElement, std::__ndk1::default_delete<SkSL::ProgramElement> >*) memory:1742
Code:
sk_sp<SkShader> GetInputShader()
{
SkBitmap bitmap;
bitmap.allocPixels(SkImageInfo::MakeN32Premul(120, 110)); bitmap.erase(SK_ColorRED,
SkIRect::MakeXYWH(0, 0, 100, 100));
sk_sp<SkImage> pImage = SkImage::MakeFromBitmap(bitmap);
SkMatrix matrix;
auto imageShader = pImage->makeShader
(SkTileMode::kDecal, SkTileMode::kDecal,
SkSamplingOptions(SkFilterMode::kNearest), matrix);
return imageShader;
}
std::string GetEffectCodeString(){
const char* sksl= R"(
uniform shader input1;
uniform shader input2;
half4 main(float2 p){
// Sample the source texture
float4 src1 = float4(
input1.eval(p) ); // src
float4 src2 = float4(
input2.eval(p) ); // dst
return half4( src1.rgb
* src2.a / 0.5, src2.a );
})";
return std::string(sksl);
}
void draw(SkCanvas* canvas) {
sk_sp<SkShader> inShader =
GetInputShader();
sk_sp<SkShader> inShader2 =
GetInputShader();
std::string sksl = GetEffectCodeString();
auto [effect, err] =
SkRuntimeEffect::MakeForShader(SkString(sksl.c_str()));
sk_sp<SkShader> children[] =
{inShader, inShader2};
sk_sp<SkShader> outShader =
effect->makeShader(nullptr, children, 2, nullptr, true);
SkPaint paint;
paint.setShader(outShader);
canvas->drawPaint(paint);
}
Any help is appreciated, thanks in advance.