-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
The application may be doing too much work on its main thread. #84
Comments
Are you using OkHttp networking stack? |
@plamenko I just used in a CircleView Adapter and load image, very simple like the tutorial. |
What's |
Hitting the same problem here. Pretty basic usage of // MainActivity.java
Fresco.initialize(this);
GridView gv = findViewById(R.id.grid_view);
ImageAdapter ia = new ImageAdapter(this);
gv.setAdapter(ia); // ImageAdapter.java
public class ImageAdapter extends BaseAdapter {
...
public View getView(int position, View convertView, final ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.grid_item, null);
convertView.setTag(convertView.findViewById(R.id.grid_item_image_view));
}
SimpleDraweeView view = (SimpleDraweeView) convertView.getTag();
// with the following line: major UI slowdown, "the application may be doing too much work on its main thread."
// without the following line: performant as expected
view.setImageURI(Uri.parse("content://media/external/images/media/172699");
return view;
}
...
} <!-- grid_item.xml -->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/grid_item_image_view"
android:layout_width="150dp"
android:layout_height="150dp"
/>
</LinearLayout> It seems that any parallel calls to |
@plamenko My code just the same as above, in an adapter |
I'll investigate |
Replacing view.setImageURI(Uri.parse("content://..."); with ImageRequest imageRequest =
ImageRequestBuilder.newBuilderWithSource(Uri.parse("content://...")
.setResizeOptions(
new ResizeOptions(150, 150))
.build();
DraweeController draweeController = Fresco.newDraweeControllerBuilder()
.setImageRequest(imageRequest)
.setOldController(view.getController())
.setAutoPlayAnimations(true)
.build();
view.setController(draweeController); in my code above fixes the performance problem. If I comment out the |
FWIW I can also hack the Fresco Sample app to Replace these lines with
I've found it only hits performance problems dealing with local |
That's really helpful information, thanks! |
@fuwaneko , yeah OkHttp cancellation is a known issue and we have a fix for that. However, local content uri is something we yet need to figure. |
One other potential/related clue. Even when using my workaround above (which fixed the performance problem), I still see one error line for every
The image still successfully loads but an error is generated for each. The fix from this Picasso thread is to include |
I deleted the two comments related to OkHttp cancellation as they are not related to this issue and has already been fixed. |
@mikeknoop , I missed part of your commend earlier, where you said "If I comment out the setResizeOptions line the performance problem comes back." |
@plamenko my local images are indeed bigger than the view. They are camera images so likely ~3000x3000px getting scaled to ~150dpi views. Can Fresco handle this use case? |
@mikeknoop, yes, please see http://frescolib.org/docs/resizing-rotating.html#_ |
Thanks for the info. I imagine Camera images are the 80% use case for I feel like I'm really hacking things to get Fresco to work:
Resizing to 1x1 seems to pick some minimum size that is suitable. I should add that I haven't been able to beat Picasso w.r.t. loading performance for |
You should definitely specify resizing, but
|
Same issue, after using SimpleDraweeView:
In my case I have init the Fresco in Application, in the adapter use setImageUrl, then the app is closing to ANR with few response;
|
I just get the width and height when setImageUri() public void setImageURI(Uri uri, @nullable Object callerContext) {
/**
|
Setting ResizeOptions is indeed the correct solution. The reason frames were skipped is that Android was struggling to scale such a large image in a small view. At most we could make this automatic some of the time - when the view is specified with an explicit size - but that won't work for match_parent type layouts. |
Hello, I got entangled in a similar problem where i was using SimpleDraweeView as a GridView row, to parse some http uri's. All images were > 5mb and were being loaded in memory without getting resized automatically (which was causing Out of Memory Error). @mikeknoop 's solution works but writing such code in getView() seems an inefficient approach. So, i created my version of SimpleDraweeView, following are the steps i used:
that's all! |
Hi ! I had the same problem and what fixed it was to Regarding this issue, can someone from fresco answer me these questions:
|
I also thave the same issue, my app has images and uses fragments and adapters but it is too slow. This is how my adpater looks like;
}` An the fragment looks like this;
}` Please what could be wrong? |
need help |
need help
|
I used SimpleDraweeView in adapter, but my app runs slowly, and I saw the log below:
I/Choreographer(1378): Skipped 55 frames! The application may be doing too much work on its main thread.
so I comment the code
mSimpleDraw.setImageUri
, the app runs fluently. I think the SimpleDraw blocks the main thread when fetching image from network.The text was updated successfully, but these errors were encountered: