0

我在我的应用程序的 logcat 输出中看到了很多以下错误消息:

E/RenderScript: rsAssert failed: mSysRefCount > 0, in frameworks/rs/rsObjectBase.cpp at 147

尽管如此,该应用程序确实大部分工作,但有时它会在启动 RenderScript 代码几次后与 SIGSEGV 一起崩溃。

我能够找到问题(嗯,我认为)。我的渲染脚本代码中有一个函数,它返回一个rs_allocation并且定义和使用有点像这样:

rs_allocation gTmp1;
rs_allocation gTmp2;

static rs_allocation blur(float size) {
    if (some_criterion())
        return gTmp1;
    else
        return gTmp2;
}

...
rs_allocation tmp = blur(size);

将函数定义更改为以下内容后,错误消息消失了,此后应用程序没有崩溃:

static bool blur(float size) {
    if (some_criterion())
        return false;
    else
        return true;
}

...
bool blurred = blur(size);
rs_allocation tmp = blurred ? gTmp2 : gTmp1;

现在的问题是,为什么这有什么不同?毕竟rs_allocation被定义为rs_types.rshint中的指针。所以当一个函数返回一个时,应该不会发生什么太花哨的事情,对吧?rs_allocation

4

0 回答 0