简体   繁体   中英

android.support.v8.renderscript.RSRuntimeException: Loading of ScriptC script failed

I've started to work with renderscript and wonder why it doesn't work on api 16 with support mode. For example in project https://github.com/harism/android_reimage in code :

scriptInvert = new ScriptC_invert(rs);

I catch Exception :

Caused by: android.support.v8.renderscript.RSRuntimeException: Loading of ScriptC script failed. at android.support.v8.renderscript.ScriptC.(ScriptC.java:69)

at io.github.harism.lib.reimage.ScriptC_invert.(ScriptC_invert.java:42)

at io.github.harism.lib.reimage.ScriptC_invert.(ScriptC_invert.java:34)

at io.github.harism.lib.reimage.ReImage.(ReImage.java:56)

at io.github.harism.lib.reimage.ReImage.from(ReImage.java:45)

Does someone have any idea why can this happen?

Example of .rs code that failed ( https://github.com/harism/android_reimage/blob/master/reimage/src/main/rs/invert.rs ):

#pragma version(1)
#pragma rs java_package_name(io.github.harism.lib.reimage)
#pragma rs_fp_relaxed

void invert(uchar4 *inout, uint32_t x, uint32_t y) {
    inout->r = 0xFF - inout->r;
    inout->g = 0xFF - inout->g;
    inout->b = 0xFF - inout->b;
}

That's funny but I found a core of an issue... My .rs files was in library module. That caused an issue because internalCreate(rs, resources, resourceID) in ScriptC returned 0 (wasn't able to find raw .bc files).

Rename the RS function to be root if you'd like it to be automatically picked up as the kernel for your script. Or, change it to be:

void __attribute__((kernel)) invert(uchar4 *inout, uint32_t x, uint32_t y)

You will likely also run into a problem since you are not specifying an explicit output allocation. With the second form, replace the void return value with uchar4 and be sure to set an output allocation in your java code.

I think the issue here might be proguard stripping the code. Can you try disabling proguard and/or updating it to not remove anything related to the RS support library (or your custom code)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM