Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AndroidBitmap_lockPixels() failed ! error=-3 #21

Open
michgauz opened this issue Apr 4, 2014 · 4 comments
Open

AndroidBitmap_lockPixels() failed ! error=-3 #21

michgauz opened this issue Apr 4, 2014 · 4 comments

Comments

@michgauz
Copy link

michgauz commented Apr 4, 2014

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.

@Dr-Emann
Copy link
Contributor

Dr-Emann commented Apr 5, 2014

Hmm, looks like -3 from lockPixels is ANDROID_BITMAP_RESULT_ALLOCATION_FAILED according to bitmap.h. Not entirely certain what that means.

Can you give a little more information about your environment? What bitmap, what android version, device/emulator, etc?

@michgauz
Copy link
Author

michgauz commented Apr 7, 2014

I'm working on my Nexus 5 on 4.4.2.
I am loading cache data, and after network data that contains jpeg links.
I use Aquery, and its callback to get the bitmap and apply the blur.

Thanks.

@illarionov
Copy link
Contributor

I have the same problem on Nexus 5 Android L developer preview and on Samsung Galaxy S2 android 4.1.2. Looks like AndroidBitmap_lockPixels() creates a copy of the buffer for each thread and often goes out of memory.
I have tested it using BlurTestAndroid (pull request)
There is also a missing return statement in blur.c: blur.c, fix on line 321
logcat:

D/BlurBenchmarkTask(16459): Start test with 24px radius, 100rounds in NDK_STACKBLUR
D/BlurBenchmarkTask(16459): Warmup
I/art     (16459): Background sticky concurrent mark sweep GC freed 4909(168KB) AllocSpace objects, 94(14MB) LOS objects, 287% free, 43MB/51MB, paused 19.776ms total 126.307ms
D/BlurBenchmarkTask(16459): Start benchmark
I/art     (16459): Background partial concurrent mark sweep GC freed 3482(193KB) AllocSpace objects, 32(22MB) LOS objects, 430% free, 29MB/37MB, paused 20.659ms total 155.613ms
W/libc    (16459): pthread_create failed: couldn't allocate 1081344-byte stack: Out of memory
E/art     (16459): Throwing OutOfMemoryError "pthread_create (1056KB stack) failed: Try again"
E/BlurBenchmarkTask(16459): Could not complete benchmark
E/BlurBenchmarkTask(16459): java.lang.OutOfMemoryError: pthread_create (1056KB stack) failed: Try again
E/BlurBenchmarkTask(16459):     at java.lang.Thread.nativeCreate(Native Method)
E/BlurBenchmarkTask(16459):     at java.lang.Thread.start(Thread.java:1063)
E/BlurBenchmarkTask(16459):     at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:920)
E/BlurBenchmarkTask(16459):     at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1327)
E/BlurBenchmarkTask(16459):     at java.util.concurrent.AbstractExecutorService.invokeAll(AbstractExecutorService.java:207)
E/BlurBenchmarkTask(16459):     at at.favre.app.blurbenchmark.blur.algorithms.NdkStackBlur.blur(NdkStackBlur.java:62)
E/BlurBenchmarkTask(16459):     at at.favre.app.blurbenchmark.util.BlurUtil.blur(BlurUtil.java:44)
E/BlurBenchmarkTask(16459):     at at.favre.app.blurbenchmark.BlurBenchmarkTask.doInBackground(BlurBenchmarkTask.java:102)
E/BlurBenchmarkTask(16459):     at at.favre.app.blurbenchmark.BlurBenchmarkTask.doInBackground(BlurBenchmarkTask.java:31)
E/BlurBenchmarkTask(16459):     at android.os.AsyncTask$2.call(AsyncTask.java:288)
E/BlurBenchmarkTask(16459):     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
E/BlurBenchmarkTask(16459):     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
E/BlurBenchmarkTask(16459):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
E/BlurBenchmarkTask(16459):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
E/BlurBenchmarkTask(16459):     at java.lang.Thread.run(Thread.java:818)
D/BlurBenchmarkFragment(16459): next test
D/BlurBenchmarkTask(16459): Start test with 24px radius, 100rounds in NDK_STACKBLUR
D/BlurBenchmarkTask(16459): Warmup
F/libc    (16459): new failed to allocate 524288 bytes
F/libc    (16459): Fatal signal 6 (SIGABRT), code -6 in tid 17998 (AsyncTask #2)
I/DEBUG   ( 3454): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   ( 3454): Build fingerprint: 'google/hammerhead/hammerhead:L/LPV79/1236599:user/release-keys'
I/DEBUG   ( 3454): Revision: '11'
I/DEBUG   ( 3454): pid: 16459, tid: 17998, name: AsyncTask #2  >>> at.favre.app.blurbenchmark.debug <<<
I/DEBUG   ( 3454): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
I/DEBUG   ( 3454): Abort message: 'new failed to allocate 524288 bytes'
I/DEBUG   ( 3454): AM write failure (32 / Broken pipe)
I/DEBUG   ( 3454):     r0 00000000  r1 0000464e  r2 00000006  r3 00000000
I/DEBUG   ( 3454):     r4 00000006  r5 0000000c  r6 0000464e  r7 0000010c
I/DEBUG   ( 3454):     r8 00000fb6  r9 00080001  sl 4ca8e008  fp 0003fc40
I/DEBUG   ( 3454):     ip 00040bf6  sp 5f130ff0  lr b6f74371  pc b6f970d0  cpsr 000f0010
I/DEBUG   ( 3454):     d0  ffffffffffffffff  d1  ffffffffffffffff
I/DEBUG   ( 3454):     d2  0000000000000000  d3  0000000000000000
I/DEBUG   ( 3454):     d4  0000000000080000  d5  61642f6d656d6873
I/DEBUG   ( 3454):     d6  646e692d6b69766c  d7  6572207463657269
I/DEBUG   ( 3454):     d8  0000000000000000  d9  0000000000000000
I/DEBUG   ( 3454):     d10 0000000000000000  d11 0000000000000000
I/DEBUG   ( 3454):     d12 0000000000000000  d13 0000000000000000
I/DEBUG   ( 3454):     d14 0000000000000000  d15 0000000000000000
I/DEBUG   ( 3454):     d16 0000000000000000  d17 0000000000000fff
I/DEBUG   ( 3454):     d18 b83cebe17b8a8e4c  d19 8d4c8e92508d9250
I/DEBUG   ( 3454):     d20 8e00000000909453  d21 e07b8a8e4c8e9250
I/DEBUG   ( 3454):     d22 46268f93518d9250  d23 9a55fbfbfb010000
I/DEBUG   ( 3454):     d24 ffa5974effa69a55  d25 ffa19749ffa79a4e
I/DEBUG   ( 3454):     d26 0000433d374b4540  d27 15133e3e362e2d25
I/DEBUG   ( 3454):     d28 ffffffffffffffff  d29 ffffffffffffffff
I/DEBUG   ( 3454):     d30 4b00433d37080809  d31 11011d181b191417
I/DEBUG   ( 3454):     scr 60000013
I/DEBUG   ( 3454): 
I/DEBUG   ( 3454): backtrace:
I/DEBUG   ( 3454):     #00 pc 000390d0  /system/lib/libc.so (tgkill+12)

@illarionov
Copy link
Contributor

The Implementation using native threads works at least as fast, and this error does not occur: blur.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants