Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps

Showing 1-28 of 28 messages
Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Ash McConnell 8/1/11 7:45 AM
Hi Folks,

I am coming across an error when I am updating my RemoteViews in my
AppWidget.

!!! FAILED BINDER TRANSACTION !!!

This is caused because all the changes to the RemoteViews are
serialised (e.g. setInt and setImageViewBitmap ). The bitmaps are also
serialised into an internal bundle. Unfortunately this bundle has a
very small size limit.

I cannot use setImageResource as I am hoping to allow the user to
download skins for the widget.

Can anyone recommend a workaround for this problem? I am already using
a "new" RemoteViews object for each instance of the widget, but a
single instance contains too many updates.

All the best,
Ash
Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Kostya Vasilyev 8/1/11 7:53 AM
If you are overflowing the binder RPC mechanism, maybe your bitmap
really is too large, and would cause performance problems even if it
went through.

There are other ways to push a dynamically generated bitmap into a
widget, perhaps you should consider those.

-- Kostya

01.08.2011 18:45, Ash McConnell пишет:

--
Kostya Vasilyev

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Ash McConnell 8/1/11 8:02 AM
Hi Kostya,

It's not that the single bitmap is too large, it's that I'm updating quite a few bitmaps.  The biggest bitmap in PNG form (a lot smaller I know) is only 4KB. I am updating 14 ImageViews in each update.  Is there any way to split the update for each widget instance somehow?

What are the other methods to push a bitmap into a widget?  Anything I could search for?

Thanks for your help!
All the best,
Ash
Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Kostya Vasilyev 8/1/11 8:18 AM

01.08.2011 19:02, Ash McConnell пишет:

> Hi Kostya,
>
> It's not that the single bitmap is too large, it's that I'm updating
> quite a few bitmaps. The biggest bitmap in PNG form (a lot smaller I
> know) is only 4KB. I am updating 14 ImageViews in each update. Is
> there any way to split the update for each widget instance somehow?

Binder data size limit is 512K, IIRC, so it should be enough for the update.

Are you sure the failed transaction is not caused by bad data in
RemoteViews (references to views that don't exist, etc.) that cause the
remote side (Launcher) to crash?

>
> What are the other methods to push a bitmap into a widget? Anything I
> could search for?

ImageView can grab images from a Uri, and supports content:// and
file:// style Uris.

-- Kostya

>
> Thanks for your help!
> All the best,
> Ash

--
Kostya Vasilyev

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Dianne Hackborn 8/1/11 9:06 AM
It is actually 1MB.  The most common reason for this error is a too large IPC.  As a quick test, you could try removing half the bitmaps or so and see if it works.  If so, the issue is almost certainly an IPC that is too large.  If that is the case, you just need to reduce the amount of data being sent over.



--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Ash McConnell 8/1/11 9:23 AM
Hi Kostya / Dianne,

Thanks for the replies.  As Dianne suggested, removing half the bitmaps does indeed make it work.

I can't really reduce the amount of bitmaps, so I am trying to use the setImageURI on ImageView.  Unfortunately I am getting permission denied errors.

Here is the test code I used: -

                File file = new File(context.getFilesDir().getAbsolutePath() + "/skins/Minimal/flight_on.png");
if (file.exists()){
Uri uri = Uri.fromFile(file);
Log.i(LOGTAG, uri.toString());
views.setUri(R.id.buttonSound, "setImageURI", uri);
}


The file *does* exist and I get the following log message: -

08-01 17:19:20.304: INFO/WidgetTest(4563): file:///data/data/sirocco.widgets/files/skins/Minimal/flight_on.png

I didn't think I would have permission problems with the widget's own files.  Is there a problem with accessing these files from a widget (actually a private service class within the widget)?

Thanks again for your help
All the best,
Ash

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Dianne Hackborn 8/1/11 9:28 AM
Those files aren't be accessed by you, they are being opened by another app (the launcher) when it applies your RemoteViews to the widget it is displaying.

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Ash McConnell 8/1/11 9:40 AM
Ah ok, I copy the files over into the skins directory in my configuration activity.  I currently use normal java.io.FileOutputStream objects, should I be using context.openFileOutput with MODE_WORLD_READABLE set?
Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Kostya Vasilyev 8/1/11 10:19 AM
That should work.

01.08.2011 20:40, Ash McConnell пишет:
Ah ok, I copy the files over into the skins directory in my configuration activity.  I currently use normal java.io.FileOutputStream objects, should I be using context.openFileOutput with MODE_WORLD_READABLE set? 

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Ash McConnell 8/1/11 11:05 AM
Thanks Kostya and Dianne, setUri works as expected.  I had to create the files using context.openFileOutput.  Unfortunately that means I loose the ability to use directories.  I can't see a "Java" way to set permission on files, it can be done with native methods, but that seems like overkill.  I'll do some more googling.

Thanks again for the help, I was worried that this problem might have been a show-stopper.
Ash

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Kostya Vasilyev 8/1/11 11:20 AM
Well, there is File.setReadable, which is supposed to be able to change
the permissions, but I've never tried it myself....

01.08.2011 22:05, Ash McConnell пишет:

--
Kostya Vasilyev

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Ash McConnell 8/2/11 3:10 AM
Odd that File.setReadable doesn't seem to be available on my JDK installation (the latest version of 1.6)
Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Ash McConnell 8/2/11 6:47 AM
It's because Android implemented Java.io.File and didn't include File.setReadable until API 9 (I am using API 8)
Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Efi Merdler-Kravitz 9/16/11 3:44 PM
Hi,

I'm encountering exactly the same problem,however I'm not getting my failed bind transaction immediately, it looks like it happens after a certain amount of widget updates.
The initial size is small enough to succeed and the image size is small ( I'm always updating a small single image ~ 4K).

In order to to conserve resources I'm not inflating my widget on each update instead I'm using the same RemoteViews only updating the image, for example:

// Use cached value.
RemoteViews returnValue = mRemoteViewCreator.getRemoteView();
returnValue.setImageViewBitmap(R.id.imgTextWithImage, myImg);
...
appWidgetManager.updateAppWidget(thisWidget, returnValue);

Couple of questions:
1. Does it make sense to update the widget this way ? Is it really faster ?
2. How do I know what is size that is transferred through the IPC mechanism ?

Thank you.
Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Yuvi 2/17/12 12:56 PM
Hi,

sorry to resurrect this post...but I got into a similar problem. And as the OP did, I'm using RemoteViews.setImageViewUri() to set my image on the appwidget. However I noticed that my image is being scaled according to the screen density.

So, for example, on an XHDPI screen, if I have a bitmap which is 100x100 and I set it using setImageViewBitmap() I get the image to look as 100x100. However, if I store that bitmap into a png on disk, and then use setImageViewUri() my bitmap is displayed as 50x50.

Do you know if there is a way to change this behavior? (i.e. if my image is 100x100 I'd like it to remain 100x100 also after it is decoded).
Maybe there is a way to force some density on the ImageView itself?

My only workaround (which sucks..) is to scale-up the bitmap before storing on disk so that when it is being decoded I get back my original size. But in this way I use more memory to save the image and I also loose image quality..:(

I hope someone can help me!
Thanks,
Yuvi


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
YuviDroid
Check out Launch-X (a widget to quickly access your favorite apps and contacts!)
http://android.yuvalsharon.net

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Dianne Hackborn 2/17/12 5:19 PM
Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Yuvi 2/18/12 5:40 AM
Hi Dianne,

thanks for your reply. The problem is that I'm using RemoteViews.setImageViewUri(), so I don't have a bitmap object to set the density.
The Uri I'm using is "content://..." which reaches my ContentProvider at the method openFile(Uri,String).

I looked at the Android source code and I see that ImageView.setImageUri() uses resolveUri(), and for the content scheme it calls Drawable.createFromStream(mContext.getContentResolver().openInputStream(mUri), null); which calls my openFile() method, which I implemented like this:
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
    File file = new File(getContext().getFilesDir(), "MyFile.png");

    return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
}

I don't see where I can change the density to use. :(


Thanks,
Yuvi
Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Mark Murphy 2/18/12 5:57 AM
On Sat, Feb 18, 2012 at 8:40 AM, YuviDroid <yuvi...@gmail.com> wrote:
> thanks for your reply. The problem is that I'm using
> RemoteViews.setImageViewUri(), so I don't have a bitmap object to set the
> density.

Then switch to setBitmap() or setImageViewBitmap().

--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Yuvi 2/18/12 6:07 AM
Hi Mark,

I actually switched from setImageViewBitmap() to setImageViewUri() because sometimes I need to display large bitmaps which do not work if I use setImageViewBitmap().


Yuvi


--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
YuviDroid
Check out Launch-X (a widget to quickly access your favorite apps and contacts!)
http://android.yuvalsharon.net

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Yuvi 2/19/12 1:52 PM
I tried also to set the bitmap density before saving it to disk...just in case it made any difference...but it doesn't.
No one has a solution to this issue?


Thanks,
Yuvi
Re: Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Dusk Jockeys Android Apps 2/19/12 10:36 PM
Could you not play with the xml settings of the ImageView itself? I
think there are some attributes there that control how the image is
displayed, whether or not it is scaled, centred etc.

On Feb 18, 4:56 am, YuviDroid <yuvidr...@gmail.com> wrote:
> Hi,
>
> sorry to resurrect this post...but I got into a similar problem. And as the
> OP did, I'm using RemoteViews.setImageViewUri() to set my image on the
> appwidget. However I noticed that my image is being scaled according to the
> screen density.
>
> So, for example, on an XHDPI screen, if I have a bitmap which is 100x100
> and I set it using setImageViewBitmap() I get the image to look as 100x100.
> However, if I store that bitmap into a png on disk, and then use
> setImageViewUri() my bitmap is displayed as 50x50.
>
> Do you know if there is a way to change this behavior? (i.e. if my image is
> 100x100 I'd like it to remain 100x100 also after it is decoded).
> Maybe there is a way to force some density on the ImageView itself?
>
> My only workaround (which sucks..) is to scale-up the bitmap before storing
> on disk so that when it is being decoded I get back my original size. But
> in this way I use more memory to save the image and I also loose image
> quality..:(
>
> I hope someone can help me!
> Thanks,
> Yuvi
>
> On Mon, Aug 1, 2011 at 8:05 PM, Ash McConnell <ash.mcconn...@gmail.com>wrote:
>
>
>
>
>
> > Thanks Kostya and Dianne, setUri works as expected.  I had to create the
> > files using context.openFileOutput.  Unfortunately that means I loose the
> > ability to use directories.  I can't see a "Java" way to set permission on
> > files, it can be done with native methods, but that seems like overkill.
> >  I'll do some more googling.
>
> > Thanks again for the help, I was worried that this problem might have been
> > a show-stopper.
> > Ash
>
> >  --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-d...@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> YuviDroid
> Check out Launch-X <http://android.yuvalsharon.net/launchx.php> (a widget
> to quickly access your favorite apps and contacts!)http://android.yuvalsharon.net- Hide quoted text -
>
> - Show quoted text -
Re: [android-developers] Re: Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Yuvi 2/20/12 8:21 AM
Yep I played with the xml attributes (such as scaleType)...but none would change the density being used. Or did I miss that?
Check out Launch-X (a widget to quickly access your favorite apps and contacts!)
http://android.yuvalsharon.net

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Yuvi 2/23/12 9:28 AM
I think I found the problem...and it looks like it's an Android bug.
Drawable.createFromStream() doesn't take as parameter a Resources object, and later it calls Drawable.createFromResourceStream() passing 'null' as the Resources parameter.
From my understanding the resources are then used to ensure that the drawable will set its target density correctly, but by being 'null' some default density is used.
Re: Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Efi Merdler-Kravitz 2/29/12 1:48 AM
I think that medium density is being used by default. The only way I
found to "bypass" it is by using explicit width and height in the xml
layout, e.g.
<ImageView
        android:id="@+id/imageView1"
        android:layout_width="480px"
        android:layout_height="200px" />

other, better ideas are welcomed.
Re: Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Efi Merdler-Kravitz 3/1/12 2:27 AM
YuviDroid, confirmed your bug, happens on the BitmapDrawable
constructor, the DENSITY_DEFAULT is being used which is medium
density.

On Feb 29, 11:48 am, Efi Merdler-Kravitz <efi.merd...@gmail.com>
wrote:
Re: Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Efi Merdler-Kravitz 3/1/12 2:56 AM
I can see there is already an open bug -  http://code.google.com/p/android/issues/detail?id=22590 you are more than welcomed to star it.

On Thursday, March 1, 2012 12:27:56 PM UTC+2, Efi Merdler-Kravitz wrote:
YuviDroid, confirmed your bug, happens on the BitmapDrawable
constructor, the DENSITY_DEFAULT is being used which is medium
density.

On Feb 29, 11:48 am, Efi Merdler-Kravitz <efi.merd...@gmail.com>
wrote:
> I think that medium density is being used by default. The only way I
> found to "bypass" it is by using explicit width and height in the xml
> layout, e.g.
> <ImageView
>         android:id="@+id/imageView1"
>         android:layout_width="480px"
>         android:layout_height="200px" />
>
> other, better ideas are welcomed.
>
> On Feb 23, 7:28 pm, YuviDroid <yuvidr...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I think I found the problem...and it looks like it's an Android bug.
> > Drawable.createFromStream() doesn't take as parameter a Resources object,
> > and later it calls Drawable.createFromResourceStream() passing 'null' as
> > the Resources parameter.
> > From my understanding the resources are then used to ensure that the
> > drawable will set its target density correctly, but by being 'null' some
> > default density is used.
Re: [android-developers] Re: Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Yuvi 3/1/12 4:00 AM
Uhh great!
I just added a comment + starred.

I hope more devs will star it too so it gets some attention..


Cheers,
Yuvi

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
YuviDroid
Check out Launch-X (a widget to quickly access your favorite apps and contacts!)
http://android.yuvalsharon.net

Re: [android-developers] Avoiding FAILED BINDER TRANSACTION error when updating lots of widget bitmaps Michael Lamers 4/3/12 3:50 AM
 
Hi,
 
I have the same problem using setImageURI. The problem seems to be worse than just a scaling issue.
It seems that some vendors have fixed this bug for some of their devices.
I have a HTC Sensation that doesn't scale the image set through setImageURI. All other devices I know do.
For me the only workaround for this is to measure the applied scaling by instantiating an ImageView that consumes a sample image from my ContentProvider. The extra scaling for the images that has to be applied can be calculated by comparing the ImageViews size to the original size of the sample image.
 
Fixing this bug wouldn't change anything for the next 2 years as most of us developers want to support not only the last generation of Android devices ;)
 
Greetings
 
Michael

Am Freitag, 17. Februar 2012 21:56:40 UTC+1 schrieb Yuvi:
Hi,

sorry to resurrect this post...but I got into a similar problem. And as the OP did, I'm using RemoteViews.setImageViewUri() to set my image on the appwidget. However I noticed that my image is being scaled according to the screen density.

So, for example, on an XHDPI screen, if I have a bitmap which is 100x100 and I set it using setImageViewBitmap() I get the image to look as 100x100. However, if I store that bitmap into a png on disk, and then use setImageViewUri() my bitmap is displayed as 50x50.

Do you know if there is a way to change this behavior? (i.e. if my image is 100x100 I'd like it to remain 100x100 also after it is decoded).
Maybe there is a way to force some density on the ImageView itself?

My only workaround (which sucks..) is to scale-up the bitmap before storing on disk so that when it is being decoded I get back my original size. But in this way I use more memory to save the image and I also loose image quality..:(

I hope someone can help me!
Thanks,
Yuvi

On Mon, Aug 1, 2011 at 8:05 PM, Ash McConnell  wrote:
Thanks Kostya and Dianne, setUri works as expected.  I had to create the files using context.openFileOutput.  Unfortunately that means I loose the ability to use directories.  I can't see a "Java" way to set permission on files, it can be done with native methods, but that seems like overkill.  I'll do some more googling.

Thanks again for the help, I was worried that this problem might have been a show-stopper.
Ash

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
YuviDroid
Check out Launch-X (a widget to quickly access your favorite apps and contacts!)
http://android.yuvalsharon.net

More topics »