I'm creating an app that's supposed to show some images on a Fragment
, most of them downloaded from the internet.
I'm using Glide to handle that image loading for me on my CardViews and Fresco on my image slider (And this question on SO explains why I'm using two image libs).
The Fresco part of the lib is mostly based on this fork of the AndroidImageSlider
.
Important: The images that I'm trying to load can either be PNG
or SVG
.
More info: I'm using a Moto Maxx (international version of the Droid Turbo) running Android 5.0.2. Also happened on a Samsung Galaxy S4 running Android 4.4.2 (cyanogen mod), but it happens a lot less often.
P.S.: I'm NOT using NDK.
Sometimes, my app just crashes, out of nowhere, and even without any user interaction. And when it does, I'm getting the following error message on the logcat:
Fatal signal 7 (SIGBUS), code 2, fault addr 0x9a74c060 in tid 21894
Full stack:
04-07 07:59:08.110 21894 21894 F libc : Fatal signal 7 (SIGBUS), code 2, fault addr 0x9a74c060 in tid 21894 (asus.saitestore)
04-07 07:59:08.161 21946 21946 E Diag_Lib: Diag_LSM_Init: Failed to open handle to diag driver, error = 2
04-07 07:59:08.263 333 333 I DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-07 07:59:08.263 333 333 I DEBUG : Build fingerprint: 'motorola/quark_retbr/quark_umts:5.0.2/LXG22.33-12.16/16:user/release-keys'
04-07 07:59:08.263 333 333 I DEBUG : Revision: 'p4a0'
04-07 07:59:08.263 333 333 I DEBUG : ABI: 'arm'
04-07 07:59:08.263 333 333 I DEBUG : pid: 21894, tid: 21894, name: asus.saitestore >>> org.unasus.saitestore <<<
04-07 07:59:08.264 333 333 I DEBUG : signal 7 (SIGBUS), code 2 (BUS_ADRERR), fault addr 0x9a74c060
04-07 07:59:08.446 333 333 I DEBUG : r0 00000000 r1 bead50cc r2 00000000 r3 9dae4000
04-07 07:59:08.446 333 333 I DEBUG : r4 9dae4000 r5 9a74c060 r6 bead50d4 r7 00000001
04-07 07:59:08.446 333 333 I DEBUG : r8 00063054 r9 00000000 sl 000000fe fp 00000000
04-07 07:59:08.446 333 333 I DEBUG : ip 00000000 sp bead5094 lr b5952d63 pc b5a38426 cpsr 800b0030
04-07 07:59:08.447 333 333 I DEBUG :
04-07 07:59:08.447 333 333 I DEBUG : backtrace:
04-07 07:59:08.447 333 333 I DEBUG : #00 pc 001b2426 /system/lib/libskia.so (S32_opaque_D32_nofilter_DX_neon(SkBitmapProcState const&, unsigned int const*, int, unsigned int*)+141)
04-07 07:59:08.447 333 333 I DEBUG : #01 pc 000ccd61 /system/lib/libskia.so (SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int, int, unsigned int*, int)+86)
04-07 07:59:08.447 333 333 I DEBUG : #02 pc 000d6cff /system/lib/libskia.so (SkARGB32_Shader_Blitter::blitV(int, int, int, unsigned char)+528)
04-07 07:59:08.447 333 333 I DEBUG : #03 pc 001076c1 /system/lib/libskia.so
04-07 07:59:08.447 333 333 I DEBUG : #04 pc 0010782d /system/lib/libskia.so
04-07 07:59:08.447 333 333 I DEBUG : #05 pc 001078b9 /system/lib/libskia.so
04-07 07:59:08.447 333 333 I DEBUG : #06 pc 00107cf3 /system/lib/libskia.so (SkScan::AntiFillRect(SkRect const&, SkRegion const*, SkBlitter*)+178)
04-07 07:59:08.447 333 333 I DEBUG : #07 pc 0010804b /system/lib/libskia.so (SkScan::AntiFillRect(SkRect const&, SkRasterClip const&, SkBlitter*)+14)
04-07 07:59:08.447 333 333 I DEBUG : #08 pc 000e2031 /system/lib/libskia.so (SkDraw::drawRect(SkRect const&, SkPaint const&) const+252)
04-07 07:59:08.447 333 333 I DEBUG : #09 pc 000e3513 /system/lib/libskia.so (SkDraw::drawBitmap(SkBitmap const&, SkMatrix const&, SkPaint const&) const+276)
04-07 07:59:08.447 333 333 I DEBUG : #10 pc 000db7c5 /system/lib/libskia.so
04-07 07:59:08.447 333 333 I DEBUG : #11 pc 000db8ad /system/lib/libskia.so (SkCanvas::drawBitmap(SkBitmap const&, float, float, SkPaint const*)+116)
04-07 07:59:08.447 333 333 I DEBUG : #12 pc 000f97bb /system/lib/libskia.so (SkPicturePlayback::draw(SkCanvas&, SkDrawPictureCallback*)+1186)
04-07 07:59:08.447 333 333 I DEBUG : #13 pc 000b54c7 /system/framework/arm/boot.oat
04-07 07:59:09.190 333 333 I DEBUG : Tombstone written to: /data/tombstones/tombstone_08
04-07 07:59:09.205 806 828 I BootReceiver: Copying /data/tombstones/tombstone_08 to DropBox (SYSTEM_TOMBSTONE)
Once, it also gave me a different error message:
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x9abe300c in tid 30052
And the full stack:
04-04 15:41:34.059: A/libc(30052): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x9abe300c in tid 30052 (asus.saitestore)
04-04 15:41:34.161: I/DEBUG(28994): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-04 15:41:34.161: I/DEBUG(28994): Build fingerprint: 'motorola/quark_retbr/quark_umts:5.0.2/LXG22.33-12.16/16:user/release-keys'
04-04 15:41:34.161: I/DEBUG(28994): Revision: 'p4a0'
04-04 15:41:34.161: I/DEBUG(28994): ABI: 'arm'
04-04 15:41:34.161: I/DEBUG(28994): pid: 30052, tid: 30052, name: asus.saitestore >>> org.unasus.saitestore <<<
04-04 15:41:34.161: I/DEBUG(28994): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x9abe300c
04-04 15:41:34.177: I/DEBUG(28994): r0 00000000 r1 bede70a4 r2 00000000 r3 9ce89000
04-04 15:41:34.178: I/DEBUG(28994): r4 9ce89000 r5 9abe300c r6 bede70ac r7 00000001
04-04 15:41:34.178: I/DEBUG(28994): r8 00000000 r9 00000000 sl 000000fe fp 00000000
04-04 15:41:34.178: I/DEBUG(28994): ip 00000000 sp bede706c lr b5992d63 pc b5a78426 cpsr 800b0030
04-04 15:41:34.178: I/DEBUG(28994): backtrace:
04-04 15:41:34.178: I/DEBUG(28994): #00 pc 001b2426 /system/lib/libskia.so (S32_opaque_D32_nofilter_DX_neon(SkBitmapProcState const&, unsigned int const*, int, unsigned int*)+141)
04-04 15:41:34.178: I/DEBUG(28994): #01 pc 000ccd61 /system/lib/libskia.so (SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int, int, unsigned int*, int)+86)
04-04 15:41:34.178: I/DEBUG(28994): #02 pc 000d6cff /system/lib/libskia.so (SkARGB32_Shader_Blitter::blitV(int, int, int, unsigned char)+528)
04-04 15:41:34.178: I/DEBUG(28994): #03 pc 0010721d /system/lib/libskia.so
04-04 15:41:34.178: I/DEBUG(28994): #04 pc 00107669 /system/lib/libskia.so
04-04 15:41:34.178: I/DEBUG(28994): #05 pc 0010782d /system/lib/libskia.so
04-04 15:41:34.178: I/DEBUG(28994): #06 pc 001078b9 /system/lib/libskia.so
04-04 15:41:34.178: I/DEBUG(28994): #07 pc 00107cf3 /system/lib/libskia.so (SkScan::AntiFillRect(SkRect const&, SkRegion const*, SkBlitter*)+178)
04-04 15:41:34.179: I/DEBUG(28994): #08 pc 0010804b /system/lib/libskia.so (SkScan::AntiFillRect(SkRect const&, SkRasterClip const&, SkBlitter*)+14)
04-04 15:41:34.179: I/DEBUG(28994): #09 pc 000e2031 /system/lib/libskia.so (SkDraw::drawRect(SkRect const&, SkPaint const&) const+252)
04-04 15:41:34.179: I/DEBUG(28994): #10 pc 000e3513 /system/lib/libskia.so (SkDraw::drawBitmap(SkBitmap const&, SkMatrix const&, SkPaint const&) const+276)
04-04 15:41:34.179: I/DEBUG(28994): #11 pc 000db7c5 /system/lib/libskia.so
04-04 15:41:34.179: I/DEBUG(28994): #12 pc 000db8ad /system/lib/libskia.so (SkCanvas::drawBitmap(SkBitmap const&, float, float, SkPaint const*)+116)
04-04 15:41:34.179: I/DEBUG(28994): #13 pc 000f97bb /system/lib/libskia.so (SkPicturePlayback::draw(SkCanvas&, SkDrawPictureCallback*)+1186)
04-04 15:41:34.179: I/DEBUG(28994): #14 pc 000b54c7 /system/framework/arm/boot.oat
04-04 15:41:34.820: I/DEBUG(28994): Tombstone written to: /data/tombstones/tombstone_07
04-04 15:41:34.821: I/BootReceiver(1989): Copying /data/tombstones/tombstone_07 to DropBox (SYSTEM_TOMBSTONE)
EDIT: Also happened on a Samsung Galaxy S4, tombstone can be found here.
Inside my CardAdapter
, I'm loading the images like this (The SVG part was taken from here):
if (mod.getImg_type() == ImageTypes.SVG) {
GenericRequestBuilder<Uri, InputStream, SVG, PictureDrawable> requestBuilder;
SVGDecoder decoder = new SVGDecoder(PreserveAspectRatio.STRETCH);
requestBuilder = Glide.with(mContext)
.using(Glide.buildStreamModelLoader(Uri.class, mContext), InputStream.class)
.from(Uri.class)
.as(SVG.class)
.transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
.sourceEncoder(new StreamEncoder())
.cacheDecoder(new FileToStreamDecoder<>(decoder))
.decoder(decoder)
.placeholder(R.drawable.modulo)
.error(R.drawable.banner_error)
.animate(android.R.anim.fade_in)
.listener(new SvgSoftwareLayerSetter<Uri>());
requestBuilder
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
.load(Uri.parse(mod.getUrl_icon()))
.into(cardHolder.iv_card);
}
else {
Glide.with(mContext)
.load(mod.getUrl_icon())
.placeholder(R.drawable.modulo)
.error(R.drawable.banner_error)
.centerCrop()
.crossFade()
.into(cardHolder.iv_card);
}
And the XML
file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_width="@dimen/card_w"
android:layout_height="@dimen/card_h"
android:layout_margin="5dp"
android:stateListAnimator="@anim/raise"
card_view:cardCornerRadius="0dp"
android:foreground="?android:attr/selectableItemBackground">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/rl_card">
<ImageView
android:layout_width="@dimen/card_image_w"
android:layout_height="@dimen/card_image_h"
android:layout_centerHorizontal="true"
android:scaleType="fitXY"
android:id="@+id/iv_card"
android:src="@drawable/modulo"
android:layout_margin="@dimen/spacing_medium" />
<TextView
android:id="@+id/tv_card"
android:layout_width="@dimen/card_text_w"
android:layout_height="@dimen/card_text_h"
android:maxHeight="@dimen/card_text_h"
android:maxWidth="@dimen/card_text_w"
android:layout_below="@+id/iv_card"
android:layout_centerHorizontal="true"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:text="Bacon ipsum dolor amet duis short ribs nostrud esse tempor."
android:textSize="12sp"
android:gravity="center_horizontal"
android:layout_marginLeft="@dimen/spacing_medium"
android:layout_marginRight="@dimen/spacing_medium" />
<View
android:id="@+id/card_check"
android:layout_width="match_parent"
android:layout_height="@dimen/card_check_h"
android:maxHeight="@dimen/card_check_h"
android:layout_below="@+id/tv_card"
android:background="@color/primary_light"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</android.support.v7.widget.CardView>
I've found a few questions here on SO, but none of them really helped with my problem. And it's a bit hard to reproduce it. Sometimes the app doesn't crash at all, even after 30 minutes on the faulty screen. On the other hand, it happened just after the images were shown.
Some questions I've found:
And many others...
And here's a screenshot from the app, taken from the bug report generated by my phone:
I have seen in some places that this problem might be related to low memory. But I think that's unlikely, since my phone got 3GB or RAM, and I'm loading fewer images comparing to the native gallery app (which is not crashing on my phone).
On the other hand, the thread on the skia issue tracker suggests it's related to the SVG lib.
Update: I've found this link on the Android issue tracker, and this one on the skia issue tracker, which is most likely related to the problem.
Other update: I've removed the slider, and the app stopped crashing. I guess the problem is in there.
Yet another update: I've changed the slider to load only PNG
or only SVG
in a given time. The app only crashed while loading the SVG
images. So perhaps the problem is on the SVG lib.
Loading the SVG from a file also crashes.
I wouldn't really have a solution but I believe that I have some useful tips in order to help you digging further on the problem, but it was quite long for a comment
You already have narrow down the issue. The problem is most probably on some or all the SVG's.
So I would focus to identify if all the SVG's or some of them are causing that problem.
Navigating on the "SVG lib" code you mentioned it doesn't look that it has any native components, so I wouldn't blame it.
Checking your backtrace its quite clear that the crash is on "Skia" native library (libskia.so).
Posting bellow the human readable part of your backtrace:
/system/lib/libskia.so (S32_opaque_D32_nofilter_DX_neon(SkBitmapProcState const&, unsigned int const*, int, unsigned int*)+141)
/system/lib/libskia.so (SkBitmapProcShader::BitmapProcShaderContext::shadeSpan(int, int, unsigned int*, int)+86)
/system/lib/libskia.so (SkARGB32_Shader_Blitter::blitV(int, int, int, unsigned char)+528)
/system/lib/libskia.so (SkScan::AntiFillRect(SkRect const&, SkRegion const*, SkBlitter*)+178)
/system/lib/libskia.so (SkScan::AntiFillRect(SkRect const&, SkRasterClip const&, SkBlitter*)+14)
/system/lib/libskia.so (SkDraw::drawRect(SkRect const&, SkPaint const&) const+252)
/system/lib/libskia.so (SkDraw::drawBitmap(SkBitmap const&, SkMatrix const&, SkPaint const&) const+276)
/system/lib/libskia.so (SkCanvas::drawBitmap(SkBitmap const&, float, float, SkPaint const*)+116)
/system/lib/libskia.so (SkPicturePlayback::draw(SkCanvas&, SkDrawPictureCallback*)+1186)
Backtrace is read from top to bottom so the 1st line I posted is what exactly crashed. Some opaque thing without filter on something neon. (NEON is on the processor chip and either the device support it or not)
Some extra details about the Skia library:
Skia is an open source 2D graphics library which provides common APIs that work across a variety of hardware and software platforms. It serves as the graphics engine for Google Chrome and Chrome OS, Android, Mozilla Firefox and Firefox OS, and many other products.
Skia is sponsored and managed by Google, but is available for use by anyone under the BSD Free Software License. While engineering of the core components is done by the Skia development team, we consider contributions from any source.
So, the problem is most probably to the "Android Source Code" or the ROMs that your testing devices use. Have you tested the application on a vanila android to see if it still crashes? Or at least something that does not have some custom ROM as you may hit some limitation there. I have faced some limitations myself on custom ROMS regarding neon features but never on an OEM/Stock ROM.
Last but not least, there are some limitation when loading SVGs to Android, so another probability is to hit one of them. Googling arround I've found an article mentioning it, not sure if it the only one though.
The Android Developer reference recommends that a vector image be limited to a maximum of 200 x 200 dpi, as the initial loading of a vector graphic can be relatively expensive, leading to long draw times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With