Git Product home page Git Product logo

android-stackblur's Introduction

Hi there 👋

I'm a software engineer originally from Madrid, Spain 🇪🇸, and based in Munich, Germany 🇩🇪. I have been working as a freelancer for more than 9 years, and as a software engineer for 16 years. My main focus is Android and backend with Java and Kotlin. But I can tinker with any technology (I have some experience with Python for backend, RoR, NodeJS, Tensorflow, Scala...)

Some more background

  • 🔭 I’m currently working with Compose, KMP and Kotlin for Backend.
  • 💬 Ask me about Android, Java and Kotlin.

Twitter Follow

android-stackblur's People

Contributors

dr-emann avatar elye avatar illarionov avatar johnjohndoe avatar kikoso avatar libtastic avatar ravidsrk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-stackblur's Issues

ndk-build gives error Check that StackBlur/jni/arm64-v8a/librsjni.so exists or that its path is corret

For Faster process of Blur Image I want to use below function

StackBlurManager stackBlurManager = new StackBlurManager(bitmapFromGalleryOrCamera);
stackBlurManager.processNatively(25);

whenever I use above method .processNatively I am getting following errror
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/packageName-1/base.apk"],nativeLibraryDirectories=[/data/app/[packageName-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libblur.so"

So I have decided that I need to compile StackBlur module with NDK

but whenever I compile your StackBlur module with ndk-build I am getting following error


Android NDK: WARNING: APP_PLATFORM android-19 is larger than android:minSdkVersion 8 in /..//..//../StackBlur/AndroidManifest.xml    
Android NDK: ERROR:/..//.../StackBlur/jni/Android.mk:rsjni: LOCAL_SRC_FILES points to a missing file    
Android NDK: Check that /..//..../StackBlur/jni/arm64-v8a/librsjni.so exists  or that its path is corret

Please suggest me what is the issue? what should I need to do to resolve this

Robolectric test

I had a problem when I use Robolectric tests. Two of my test use this library but sometimes one of them works and sometimes any works.

Gradle:
compile 'com.commit451:NativeStackBlur:1.0.2'

Here is my code:

imageLoader.displayImage(urlImage, imageTitulo, options, new ImageLoadingListener() {
            @Override
            public void onLoadingStarted(String s, View view) {}
            @Override
            public void onLoadingFailed(String s, View view, FailReason failReason) {}
            @Override
            public void onLoadingComplete(String s, View view, Bitmap bitmap) {
                Bitmap bm = NativeStackBlur.process(bitmap, 10);
                imageTitulo.setImageBitmap(bm);
                imageStreetV.setImageBitmap(bitmap);
            }
            @Override
            public void onLoadingCancelled(String s, View view) {}
        });

And here is the output:

java.lang.NoClassDefFoundError: Could not initialize class com.enrique.stackblur.NativeBlurProcess

	at com.commit451.nativestackblur.NativeStackBlur.process(NativeStackBlur.java:20)
	at mx.org.inegi.denuemv.ficha.FichaFragment$6.onLoadingComplete(FichaFragment.java:303)
	at com.nostra13.universalimageloader.core.ImageLoader.displayImage(ImageLoader.java:253)
	at com.nostra13.universalimageloader.core.ImageLoader.displayImage(ImageLoader.java:365)
	at com.nostra13.universalimageloader.core.ImageLoader.displayImage(ImageLoader.java:340)
	at mx.org.inegi.denuemv.ficha.FichaFragment.setData(FichaFragment.java:296)
	at mx.org.inegi.denuemv.MapsActivityTest.openFicha(MapsActivityTest.java:153)
	at mx.org.inegi.denuemv.MapsActivityTest.openStreetViewTest(MapsActivityTest.java:123)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:523)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:226)
	at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:108)
	at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:35)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:62)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)

The App works as well but the tests failed, I don't know why they failed just sometimes.

Thanks!

I have a question of build-tools level

The defaut build-tools target is 18.1.0, but "RenderScript support mode requires Build-Tools 19.0.3 or later." appears in my Concole window.
So I change target "18.1.0" to "19.0.3" in project.properties ,and the error disappeared. Another error ,however,occur when I try to run "StackBlurDemo" as a android project.
The message is as follow:
[2015-02-05 17:25:11 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v8/renderscript/Allocation$1;
[2015-02-05 17:25:11 - StackBlurDemo] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v8/renderscript/Allocation$1;
What is the problem?I don't understand it.

Does it work well on SurfaceView?

SurfaceView is not supported on many libs.They just get a bitmap by activity cutting ,then they blur this bitmap. However it is not work on SurfaceView.Others get blur bitmap by root phone. Google's api can do this,but it need some Athority.

error: Non-root compute kernel blur_v() is not supported in SDK levels 11-15 & error: Non-root compute kernel blur_h() is not supported in SDK levels 11-15

when I clean the library using the eclipse ,some errors appear in file blur.rs。
like this:
error: Non-root compute kernel blur_v() is not supported in SDK levels 11-15
warning: implicit declaration of function 'rsSetElementAt_uchar4' is invalid in C99
error: Non-root compute kernel blur_h() is not supported in SDK levels 11-15

someone can help me ,thanks very much!

Out Of Memory error

Please find the logs.

E/AndroidRuntime(11680): Caused by: java.lang.OutOfMemoryError: Failed to allocate a 26214412 byte allocation with 13777168 free bytes and 13MB until OOM
E/AndroidRuntime(11680): at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
E/AndroidRuntime(11680): at android.graphics.Bitmap.nativeCreate(Native Method)
E/AndroidRuntime(11680): at android.graphics.Bitmap.createBitmap(Bitmap.java:885)
E/AndroidRuntime(11680): at android.graphics.Bitmap.createBitmap(Bitmap.java:909)
E/AndroidRuntime(11680): at com.enrique.stackblur.JavaBlurProcess.blur(JavaBlurProcess.java:102)
E/AndroidRuntime(11680): at com.enrique.stackblur.StackBlurManager.process(StackBlurManager.java:73)
E/AndroidRuntime(11680): at com.micromax.aroundyou.CustomContent$11.doInBackground(CustomContent.java:788)
E/AndroidRuntime(11680): at com.micromax.aroundyou.CustomContent$11.doInBackground(CustomContent.java:777)
E/AndroidRuntime(11680): at android.os.AsyncTask$2.call(AsyncTask.java:292)
E/AndroidRuntime(11680): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/AndroidRuntime(11680): ... 4 more

Support for MLKit Selfie segmentation

Have you ever considered adding support for MLKit Selfie segmentation?
That way we could build apps that only blur the background in a fast way, for video calls for example.
In this case, the processNatively function would accept the com.google.mlkit.vision.segmentation.SegmentationMask as a parameter and return an image that has its background blurred based on the mask.

R Class problem after Reference Library

Hello, I´m getting a rare error in runtime, I´ve compiled the NDK successfully and the StackBlur (library project) compiles well, but when I reference the project library in a totally new Android Application Project something is interfering with the R Class of the new project, it compiles well but when call findviewById(R.id.textView1) returns null, I've tested the Android Project before reference the library and without it findviewById(R.id.textView1) works normally.

I´ve looking around and the people getting this error agree it is something weird with the R Class, but nobody found a really stright solution.

Can you help me with this error, please?

I really want to try this awesome blur effect with the ndk implementation.

AndroidBitmap_lockPixels() failed ! error=-3

Hi,
I get an "AndroidBitmap_lockPixels() failed ! error=-3" randomly
with "Fatal signal 11 (SIGSEGV) at 0x41609c6c (code=2), thread 15102 (pool-2-thread-3)"
I tried to catch this error but no way for the moment ?
Is there a solution ?

Thank you.

Can't call getPixels() on a recycled bitmap

when i call stackBlurManager.process(5), error occurs:
java.lang.IllegalStateException: Can't call getPixels() on a recycled bitmap
at android.graphics.Bitmap.checkRecycled(Bitmap.java:383)
at android.graphics.Bitmap.getPixels(Bitmap.java:1429)

Got ArrayIndexOutOfBoundsException

StackBlurManager stackBlurManager = new StackBlurManager(bitmap);
stackBlurManager.process(50);
bitmap = stackBlurManager.getImage();

Results in:

java.lang.ArrayIndexOutOfBoundsException: length=665856; index=679981
            at com.enrique.stackblur.JavaBlurProcess.blur(JavaBlurProcess.java:103)
            at com.enrique.stackblur.StackBlurManager.process(StackBlurManager.java:65)

Demo app crashes at startup

Hello,

I've got problems with running the demo app. I've built the library succesfully but the app crashes immediately with this stack trace:

E/AndroidRuntime(30368): Process: com.example.stackblurdemo, PID: 30368
E/AndroidRuntime(30368): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.stackblurdemo/com.example.
stackblurdemo.MainActivity}: java.lang.NullPointerException: Can't inject null value into class com.example.stackblurdemo.MainActi
vity._imageView when field is not @Nullable
E/AndroidRuntime(30368):        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
E/AndroidRuntime(30368):        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
E/AndroidRuntime(30368):        at android.app.ActivityThread.access$800(ActivityThread.java)
E/AndroidRuntime(30368):        at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
E/AndroidRuntime(30368):        at android.os.Handler.dispatchMessage(Handler.java)
E/AndroidRuntime(30368):        at android.os.Looper.loop(Looper.java)
E/AndroidRuntime(30368):        at android.app.ActivityThread.main(ActivityThread.java)
E/AndroidRuntime(30368):        at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(30368):        at java.lang.reflect.Method.invoke(Method.java)
E/AndroidRuntime(30368):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
E/AndroidRuntime(30368):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
E/AndroidRuntime(30368):        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:126)
E/AndroidRuntime(30368):        at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(30368): Caused by: java.lang.NullPointerException: Can't inject null value into class com.example.stackblurdemo.M
ainActivity._imageView when field is not @Nullable
E/AndroidRuntime(30368):        at roboguice.inject.ViewListener$ViewMembersInjector.reallyInjectMemberViews(ViewListener.java:179
)
E/AndroidRuntime(30368):        at roboguice.inject.ViewListener$ViewMembersInjector.reallyInjectMembers(ViewListener.java:138)
E/AndroidRuntime(30368):        at roboguice.inject.ViewListener$ViewMembersInjector.injectViews(ViewListener.java:246)
E/AndroidRuntime(30368):        at roboguice.inject.ContextScopedRoboInjector.injectViewMembers(ContextScopedRoboInjector.java:258
)
E/AndroidRuntime(30368):        at roboguice.activity.RoboActivity.onContentChanged(RoboActivity.java:145)
E/AndroidRuntime(30368):        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java)
E/AndroidRuntime(30368):        at android.app.Activity.setContentView(Activity.java)
E/AndroidRuntime(30368):        at com.example.stackblurdemo.MainActivity.onCreate(MainActivity.java:46)
E/AndroidRuntime(30368):        at android.app.Activity.performCreate(Activity.java)
E/AndroidRuntime(30368):        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
E/AndroidRuntime(30368):        ... 13 more

I thought that it is a problem of roboguice, but regular findViewById() also always returns null. I have no idea what can be causing this problem, I tried cleaning the project many times with no luck. Referencing the library in another project also causes this problem. Any advice will be appreciated.

NoSuchFieldError

I've included the StackBlur library in my project but the processRenderScript method doesn't work. When I call it I get a NoSuchField error. I'm not sure whether it helps but in StackBlur/gen/R/raw I can see a value for blur, but under my project /gen/R/raw there are no fields. Maybe it's not being carried through?

Here's the stack trace:

03-24 11:22:38.554: E/AndroidRuntime(6967): FATAL EXCEPTION: Thread-1593
03-24 11:22:38.554: E/AndroidRuntime(6967): Process: com.smithyproductions.infinitracks, PID: 6967
03-24 11:22:38.554: E/AndroidRuntime(6967): java.lang.NoSuchFieldError: com.enrique.stackblur.R$raw.blur
03-24 11:22:38.554: E/AndroidRuntime(6967):     at com.enrique.stackblur.RSBlurProcess.blur(RSBlurProcess.java:29)
03-24 11:22:38.554: E/AndroidRuntime(6967):     at com.enrique.stackblur.StackBlurManager.processRenderScript(StackBlurManager.java:140)

The gradle build is not adding the native library to the application

I build the .so files with ndk-build and they can be found under Stackblur/libs.

If I now build the app with gradle the app crashes with this Exception:

02-07 12:24:34.652 18129-18129/com.example.stackblurdemo E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.ExceptionInInitializerError
at com.enrique.stackblur.StackBlurManager.processNatively(StackBlurManager.java:102)
at com.example.stackblurdemo.MainActivity.onBlur(MainActivity.java:143)
at com.example.stackblurdemo.MainActivity.setBlurMode(MainActivity.java:133)
at com.example.stackblurdemo.MainActivity$3.onItemSelected(MainActivity.java:89)
at android.widget.AdapterView.fireOnSelected(AdapterView.java:892)
at android.widget.AdapterView.access$200(AdapterView.java:49)
at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:860)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.UnsatisfiedLinkError: Couldn't load blur: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:535)
at com.enrique.stackblur.NativeBlurProcess.(NativeBlurProcess.java:13)
            at com.enrique.stackblur.StackBlurManager.processNatively(StackBlurManager.java:102)
            at com.example.stackblurdemo.MainActivity.onBlur(MainActivity.java:143)
            at com.example.stackblurdemo.MainActivity.setBlurMode(MainActivity.java:133)
            at com.example.stackblurdemo.MainActivity$3.onItemSelected(MainActivity.java:89)
            at android.widget.AdapterView.fireOnSelected(AdapterView.java:892)
            at android.widget.AdapterView.access$200(AdapterView.java:49)
            at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:860)
            at android.os.Handler.handleCallback(Handler.java:615)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4745)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)

Eclipse show an error after i import the project

Eclipse show an error after i import the project :
[2015-05-14 11:33:28 - StackBlur] error: error reading 'D:\android-stackblur-master\android-stackblur-master\StackBlur\src\blur.rs' error.

How to import stackblur

Download the library with git. When it has been imported into your project. First initialize your StackBlurManager to load a sample image

Could you provide more info on how to import this into android studio?. THanks

"Fatal signal 11" in native blur

Hi,

Thank you for this great lib, the java version is working very well, but I tried the native version and I got a libc﹕Fatal signal 11 (SIGSEGV) at 0x62448000 (code=2), thread 30186 (AsyncTask #3), which makes the app the shutdown immediately.

I'm really new to the NDK, from what I understand with Google it could be anything, so I'm not asking for a solution but I'm trying to see if I missed something. :)

  • I made sure the native code is only running in one thread, so it's not a concurrent access problem.
  • I can see the native logs in the logcat: Image size is: 640 680, so far so good…
  • I've put some logs in the loops of the algorithm, and from what I can see, the crash is occuring at random points during the algorithm. If I put "return;" at the beginning of the native function the app doesn't crash (but no blur, of course).

Do you have any pointer on this? I run the code in an AsyncTask, is it wrong?

Thank you for your time and keep up the good work!

Maven Central

It would be nice to have the library uploaded to maven central, and just import it via gradle!

Thanks mate!

error while importing stackblur into eclipse

Im having problems with the stackblur library:

[2014-03-12 19:51:04 - StackBlur] C:\Android Development\adt-bundle-windows-x86_64-20130917\sdk\build-tools\android-4.3\arm-linux-androideabi-ld.exe: fatal error: C:\Users\Olga\Desktop\repositorios\android-stackblur-master\StackBlur\bin\rsObj\armeabi-v7a\blur.o: attempt to map 40 bytes at offset 5876 exceeds size of file; the file may be corrupt
[2014-03-12 19:51:04 - StackBlur] C:\Users\Olga\Desktop\repositorios\android-stackblur-master\StackBlur\bin\rsObj\mips\blur.o: file not recognized: File truncated
[2014-03-12 19:51:04 - StackBlur] C:\Android Development\adt-bundle-windows-x86_64-20130917\sdk\build-tools\android-4.3\i686-linux-android-ld.exe: error: C:\Users\Olga\Desktop\repositorios\android-stackblur-master\StackBlur\bin\rsObj\x86\blur.o: section name section has wrong type: 65536
[2014-03-12 19:51:04 - StackBlur] C:\Android Development\adt-bundle-windows-x86_64-20130917\sdk\build-tools\android-4.3\i686-linux-android-ld.exe: fatal error: C:\Users\Olga\Desktop\repositorios\android-stackblur-master\StackBlur\bin\rsObj\x86\blur.o: attempt to map 0 bytes at offset 196608 exceeds size of file; the file may be corrupt

SIGSEGV still occurred

signal 11 (Address not mapped to object)

A/libc﹕ Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 1122

// size: 256 * divsum
int *dv = holderArray + 3 * wh + whMax;
for (i = 0; i < 256 * divsum; i++) {
    dv[i] = (i / divsum);
}
LOGI("end of divsum cycle");

log never prints

tested on Samsung Galaxy S3, Genymotion emulators with API 15+

i have a problem with API level.

like this:
eclipse error:
[2014-09-03 23:53:14 - StackBlur] error: target API level '18' is out of range ('11' - '17').

And , can not found ScriptC_blur .

Native crashes being reported by users

Hi,

I believe the following code is causing my app to crash on some devices:

StackBlurManager stackBlurManager = new StackBlurManager(normalBitmap);
blurredBitmap = stackBlurManager.processNatively(100);

I can't know for sure because native crashes do not provide any stack trace but there is just this one place in my code where I'm calling the method processNatively().

I'm not sure if it helps but here is the backtrace provided:
#00 pc 0000156a /data/app-lib/.../libblur.so (stackblurJob+1713)
#1 pc 00001b1d /data/app-lib/.../libblur.so (Java_com_enrique_stackblur_NativeBlurProcess_functionToBlur+96)
#2 pc 00158a64 /data/dalvik-cache/data@app@[email protected]

This crash seems to happen regardless of API level (my app runs on 4.0+) or device. I get one crash report roughly every 2 days.

Any ideas on how I can debug this or at least catch the crash somehow?

Thank you,
Ricardo

Excessive GC use

The Garbage Collector is being run (GC_FOR_MALLOC) on every blur because we're creating a new bitmap on every call. There's two ways to try to fix this.

Explicit Bitmap Re-use

The usual solution to this problem is to allow the user to pass an existing bitmap in.

StackBlurManager manager = new StackBlurManager(bitmap);
Bitmap output = Bitmap.createBitmap(
    bitmap.getWidth(),
    bitmap.getHeight,
    Bitmap.Config.ARGB_8888
);
manager.process(10, output);

Pros

  • No possible breaking changes with existing code
  • The user gets to choose if they need to recycle the bitmap

Cons

  • Most uses could benefit from recycling, but the user has to explicitly do so

Implicit Bitmap Re-use

However, because we have the StackBlurManager class which already holds a reference to the result, we could possibly reuse that bitmap. This could possibly break some existing code though! If the user holds on to a reference to the blurred bitmap, then blurs again, the first reference will be modified to be the same as the second. For example:

StackBlurManager manager = new StackBlurManager(bitmap);
Bitmap blur5px = manager.process(5);
Bitmap blur10px = manager.process(10);
// blur5px and blur10px are the same Bitmap, and both are blurred by 10px.
// The user would have to explicitly copy the bitmap if they want control of it.
Bitmap correct_blur5px = manager.process(5).copy(Bitmap.Config.ARGB_8888, false);

Another possible problem arises if the user tries to recycle the image.

StackBlurManager manager = new StackBlurManager(bitmap);
Bitmap tmp = manager.process(5);
tmp.recycle();
// User thinks they're cleaning up after themselves, but the bitmap is
// owned by the StackBlurManager.

The StackBlurManager can check if the image has been recycled before trying to blur into it, and make a new bitmap if it has been, possibly putting something in the log letting the user know they shouldn't call recycle on bitmaps owned by the manager.

Pros

  • Bitmaps are automatically recycled, using the existing _result variable in the StackBlurManager

Cons

  • Possible code breakage

Problem while import stackblur into eclipse

when I import stackblur to eclipse,every thing is ok,but there are some error report by eclipse.I don't know if other people have encountered.My problem is:
First,eclipse report three errors in the file StackBlur/src/blur.rs.
1.error: Non-root compute kernel blur_v() is not supported in SDK levels 11-15.
image

2.warning: implicit declaration of function 'rsSetElementAt_uchar4' is invalid in C99
image

3.error: Non-root compute kernel blur_h() is not supported in SDK levels 11-15
image

Second,can't find class "ScriptC_blur" in RSBlurProcess.java file.
image

And i saw that it pass param R.raw.blur ,but the file res/raw/blur is not exists in the project.

Last,the project structure is
image

Can anyone give some help? Thanks very much!

support for Nexus 9

When I try to run my app on Nexus 9 with NativeStackBlur dependency, I get the following exception:

UNCAUGHT EXCEPTION (main). Force logging out.:
java.lang.Exception: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/BLA.dev-2/base.apk"],nativeLibraryDirectories=[/data/app/BLA.dev-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "library.so"
...
Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/BLA.dev-2/base.apk"],nativeLibraryDirectories=[/data/app/BLA.dev-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "library.so"
...

The app does work on other (non 64-bit) devices.

Usage on Jetpack Compose

There isn't a straightforward way to use this on Jetpack Compose yet. Could it be possible to provide a Composable component that can use the stackblur library? Thank you!

java.lang.ArrayIndexOutOfBoundsException: length=336896; index=336896

java.lang.ArrayIndexOutOfBoundsException: length=336896; index=336896
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=336896; index=336896
at one.box.tv.utils.StackBlurManager.process(StackBlurManager.java:139)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
... 11 more

This line:
if (!alpha)
alpha = (int)(Color.alpha(originalPixels[y*_height+x])) != 255;

Can't inject null value even when field is @Nullable

I had a problem when I compiled.I used several online solutions, but it doesn't work.Here is the log.

01-31 17:03:33.523: E/AndroidRuntime(25720): Process: com.example.stackblurdemo, PID: 25720
01-31 17:03:33.523: E/AndroidRuntime(25720): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.stackblurdemo/com.example.stackblurdemo.MainActivity}: java.lang.NullPointerException: Can't inject null value into class com.example.stackblurdemo.MainActivity._imageView when field is not @nullable
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.app.ActivityThread.access$900(ActivityThread.java:141)
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1213)
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.os.Handler.dispatchMessage(Handler.java:102)
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.os.Looper.loop(Looper.java:136)
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.app.ActivityThread.main(ActivityThread.java:5072)
01-31 17:03:33.523: E/AndroidRuntime(25720): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 17:03:33.523: E/AndroidRuntime(25720): at java.lang.reflect.Method.invoke(Method.java:515)
01-31 17:03:33.523: E/AndroidRuntime(25720): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-31 17:03:33.523: E/AndroidRuntime(25720): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
01-31 17:03:33.523: E/AndroidRuntime(25720): at dalvik.system.NativeStart.main(Native Method)
01-31 17:03:33.523: E/AndroidRuntime(25720): Caused by: java.lang.NullPointerException: Can't inject null value into class com.example.stackblurdemo.MainActivity._imageView when field is not @nullable
01-31 17:03:33.523: E/AndroidRuntime(25720): at roboguice.inject.ViewListener$ViewMembersInjector.reallyInjectMemberViews(ViewListener.java:179)
01-31 17:03:33.523: E/AndroidRuntime(25720): at roboguice.inject.ViewListener$ViewMembersInjector.reallyInjectMembers(ViewListener.java:138)
01-31 17:03:33.523: E/AndroidRuntime(25720): at roboguice.inject.ViewListener$ViewMembersInjector.injectViews(ViewListener.java:246)
01-31 17:03:33.523: E/AndroidRuntime(25720): at roboguice.inject.ContextScopedRoboInjector.injectViewMembers(ContextScopedRoboInjector.java:258)
01-31 17:03:33.523: E/AndroidRuntime(25720): at roboguice.activity.RoboActivity.onContentChanged(RoboActivity.java:145)
01-31 17:03:33.523: E/AndroidRuntime(25720): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:293)
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.app.Activity.setContentView(Activity.java:1947)
01-31 17:03:33.523: E/AndroidRuntime(25720): at com.example.stackblurdemo.MainActivity.onCreate(MainActivity.java:53)
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.app.Activity.performCreate(Activity.java:5249)
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
01-31 17:03:33.523: E/AndroidRuntime(25720): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2165)
01-31 17:03:33.523: E/AndroidRuntime(25720): ... 11 more

Ormlite + stack blur not working

I'm using ormlite in the app and when i import stack blur the application stops responding.

11-04 14:07:03.646: E/AndroidRuntime(7682): FATAL EXCEPTION: main
11-04 14:07:03.646: E/AndroidRuntime(7682): Process: com.virtualx.virtualtpo, PID: 7682
11-04 14:07:03.646: E/AndroidRuntime(7682): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.virtualx.virtualtpo/com.virtualx.virtualtpo.LauncherActivity}: java.lang.IllegalStateException: Could not construct instance of helper class class com.virtualx.database.DatabaseHelper
11-04 14:07:03.646: E/AndroidRuntime(7682): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
11-04 14:07:03.646: E/AndroidRuntime(7682): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
11-04 14:07:03.646: E/AndroidRuntime(7682): at android.app.ActivityThread.access$800(ActivityThread.java:139)
11-04 14:07:03.646: E/AndroidRuntime(7682): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
11-04 14:07:03.646: E/AndroidRuntime(7682): at android.os.Handler.dispatchMessage(Handler.java:102)
11-04 14:07:03.646: E/AndroidRuntime(7682): at android.os.Looper.loop(Looper.java:136)
11-04 14:07:03.646: E/AndroidRuntime(7682): at android.app.ActivityThread.main(ActivityThread.java:5086)
11-04 14:07:03.646: E/AndroidRuntime(7682): at java.lang.reflect.Method.invokeNative(Native Method)
11-04 14:07:03.646: E/AndroidRuntime(7682): at java.lang.reflect.Method.invoke(Method.java:515)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
11-04 14:07:03.646: E/AndroidRuntime(7682): at dalvik.system.NativeStart.main(Native Method)
11-04 14:07:03.646: E/AndroidRuntime(7682): Caused by: java.lang.IllegalStateException: Could not construct instance of helper class class com.virtualx.database.DatabaseHelper
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.j256.ormlite.android.apptools.OpenHelperManager.constructHelper(OpenHelperManager.java:222)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.j256.ormlite.android.apptools.OpenHelperManager.loadHelper(OpenHelperManager.java:170)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.j256.ormlite.android.apptools.OpenHelperManager.getHelper(OpenHelperManager.java:78)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.virtualx.database.DatabaseQuery.isPersonalDataExisting(DatabaseQuery.java:21)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.virtualx.virtualtpo.LauncherActivity.onCreate(LauncherActivity.java:25)
11-04 14:07:03.646: E/AndroidRuntime(7682): at android.app.Activity.performCreate(Activity.java:5248)
11-04 14:07:03.646: E/AndroidRuntime(7682): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
11-04 14:07:03.646: E/AndroidRuntime(7682): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162)
11-04 14:07:03.646: E/AndroidRuntime(7682): ... 11 more
11-04 14:07:03.646: E/AndroidRuntime(7682): Caused by: java.lang.reflect.InvocationTargetException
11-04 14:07:03.646: E/AndroidRuntime(7682): at java.lang.reflect.Constructor.constructNative(Native Method)
11-04 14:07:03.646: E/AndroidRuntime(7682): at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.j256.ormlite.android.apptools.OpenHelperManager.constructHelper(OpenHelperManager.java:220)
11-04 14:07:03.646: E/AndroidRuntime(7682): ... 18 more
11-04 14:07:03.646: E/AndroidRuntime(7682): Caused by: java.lang.IllegalStateException: Could not load object config file
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.(OrmLiteSqliteOpenHelper.java:127)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.(OrmLiteSqliteOpenHelper.java:76)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.virtualx.database.DatabaseHelper.(DatabaseHelper.java:65)
11-04 14:07:03.646: E/AndroidRuntime(7682): ... 21 more
11-04 14:07:03.646: E/AndroidRuntime(7682): Caused by: java.sql.SQLException: DatabaseTableConfig reading from stream cannot parse line: ������������,������������������������������������@���m������@����������BC��! ����|��������������������#�A��I��29��� %������b��E�B��B��2�8��I
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.j256.ormlite.table.DatabaseTableConfigLoader.fromReader(DatabaseTableConfigLoader.java:74)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.j256.ormlite.table.DatabaseTableConfigLoader.loadDatabaseConfigFromReader(DatabaseTableConfigLoader.java:32)
11-04 14:07:03.646: E/AndroidRuntime(7682): at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.(OrmLiteSqliteOpenHelper.java:125)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.