My app got the following exceptions when trying to display a bitmap:
java.lang.RuntimeException: Could not write bitmap to parcel blob.
at android.graphics.Bitmap.nativeWriteToParcel(Native Method)
at android.graphics.Bitmap.writeToParcel(Bitmap.java:1296)
at android.widget.RemoteViews$BitmapCache.writeBitmapsToParcel(RemoteViews.java:839)
at android.widget.RemoteViews.writeToParcel(RemoteViews.java:2347)
at com.android.internal.appwidget.IAppWidgetService$Stub$Proxy.updateAppWidgetIds(IAppWidgetService.java:521)
at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:364)
at android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:431)
Do you have any idea why this error occurs? It exists only from 4.2. I don't know why and when it happens, I got these exceptions in reports only.
Thanks, Tamas
I think I have found the answer. If I check jni/android/graphics/Bitmap.cpp then I can see:
size_t size = bitmap->getSize();
android::Parcel::WritableBlob blob;
android::status_t status = p->writeBlob(size, &blob);
if (status) {
doThrowRE(env, "Could not write bitmap to parcel blob.");
return false;
}
It seems that the problem is about the bitmap size not the bitmap itself.
writeBlob function can return NO_MEMORY status if memory couldn't be allocated.
So I guess if a user sets a too large bitmap then it can fail this way.
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