I am running a FirebaseRecyclerAdapter and loading a user's profile picture into Picasso in the onBindViewHolder method. When I run the app on me Le Eco 2 device, running Android 6.0, it runs perfectly well.
However, when I run my app on a Samsung J7 Prime 2, it is giving me the following errors in logcat:
07-24 19:44:29.841 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: MSG_WINDOW_FOCUS_CHANGED 0
07-24 19:44:29.844 20565-20587/com.myapp.www V/FA: Recording user engagement, ms: 34127
07-24 19:44:29.846 20565-20587/com.myapp.www V/FA: Connecting to remote service
07-24 19:44:29.848 20565-20587/com.myapp.www V/FA: Activity paused, time: 985889282
07-24 19:44:29.854 20565-20587/com.myapp.www D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=34127, firebase_screen_class(_sc)=DisplayPostsActivity, firebase_screen_id(_si)=-1674957241664244677}]
07-24 19:44:29.881 20565-20587/com.myapp.www V/FA: Connection attempt already in progress
07-24 19:44:29.881 20565-20587/com.myapp.www D/FA: Connected to remote service
07-24 19:44:29.882 20565-20587/com.myapp.www V/FA: Processing queued up service tasks: 2
07-24 19:44:29.953 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: mHardwareRenderer.destroy()#1
07-24 19:44:29.962 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true
07-24 19:44:30.027 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: mHardwareRenderer.destroy()#1
07-24 19:44:30.038 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=false 0} surfaceGenerationChanged=false
07-24 19:44:30.039 20565-20565/com.myapp.www D/InputTransport: Input channel destroyed: fd=81
07-24 19:44:34.895 20565-20587/com.myapp.www V/FA: Inactivity, disconnecting from the service
07-24 19:46:37.623 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: mHardwareRenderer.destroy()#1
07-24 19:46:37.626 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x1 surface={isValid=false 0} surfaceGenerationChanged=false
07-24 19:46:37.649 20565-23426/com.myapp.www V/FA: Connecting to remote service
07-24 19:46:37.655 20565-23425/com.myapp.www I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
07-24 19:46:37.655 20565-23425/com.myapp.www I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
07-24 19:46:37.659 20565-23426/com.myapp.www V/FA: Activity resumed, time: 986017088
07-24 19:46:37.659 20565-20565/com.myapp.www V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
07-24 19:46:37.659 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: Relayout returned: oldFrame=[0,0][1080,1920] newFrame=[0,0][1080,1920] result=0x3 surface={isValid=true -969377792} surfaceGenerationChanged=true
07-24 19:46:37.660 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: mHardwareRenderer.initialize() mSurface={isValid=true -969377792} hwInitialized=true
07-24 19:46:37.666 20565-20594/com.myapp.www D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1080x1920]-format:1
07-24 19:46:37.680 20565-20565/com.myapp.www W/Activity: AppLock checkAppLockState locked:false verifying:false pkgName = com.myapp.www isInMultiWindowMode:false showWhenLocked:false
07-24 19:46:37.704 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: MSG_WINDOW_FOCUS_CHANGED 1
07-24 19:46:37.704 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true -969377792}
07-24 19:46:37.706 20565-20565/com.myapp.www V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@c51d7a9 nm : com.myapp.www ic=null
07-24 19:46:37.706 20565-20565/com.myapp.www I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
07-24 19:46:37.708 20565-20565/com.myapp.www D/InputTransport: Input channel constructed: fd=82
07-24 19:46:37.711 20565-23426/com.myapp.www D/FA: Connected to remote service
07-24 19:46:37.712 20565-23426/com.myapp.www V/FA: Processing queued up service tasks: 1
07-24 19:46:39.503 20565-20570/com.myapp.www I/art: Do partial code cache collection, code=43KB, data=59KB
07-24 19:46:39.503 20565-20570/com.myapp.www I/art: After code cache collection, code=42KB, data=58KB
07-24 19:46:39.503 20565-20570/com.myapp.www I/art: Increasing code cache capacity to 256KB
07-24 19:46:42.396 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: ViewPostImeInputStage processPointer 0
07-24 19:46:42.482 20565-20565/com.myapp.www D/ViewRootImpl@12b4d4f[DisplayPostsActivity]: ViewPostImeInputStage processPointer 1
07-24 19:46:42.520 20565-20565/com.myapp.www D/ScrollView: initGoToTop
07-24 19:46:42.639 20565-20565/com.myapp.www D/ScrollView: onsize change changed
07-24 19:46:42.641 20565-20565/com.myapp.www D/ScrollView: initGoToTop
07-24 19:46:42.738 20565-20565/com.myapp.www D/ScrollView: onsize change changed
07-24 19:46:42.773 20565-20572/com.myapp.www W/art: Suspending all threads took: 29.264ms
07-24 19:46:42.795 20565-20594/com.myapp.www W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3438x8658, max=8192x8192)
07-24 19:46:42.813 20565-20594/com.myapp.www W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3438x8658, max=8192x8192)
07-24 19:46:42.814 20565-23426/com.myapp.www V/FA: Inactivity, disconnecting from the service
07-24 19:46:42.817 20565-20565/com.myapp.www D/ScrollView: initGoToTop
07-24 19:46:42.867 20565-20594/com.myapp.www W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3438x8658, max=8192x8192)
07-24 19:46:42.868 20565-20594/com.myapp.www W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3438x8658, max=8192x8192)
07-24 19:46:42.868 20565-20594/com.myapp.www W/OpenGLRenderer: Bitmap too large to be uploaded into a texture (3438x8658, max=8192x8192)
07-24 19:46:42.868 20565-20594/com.myapp.www A/OpenGLRenderer: failed storing bitmap shader data
07-24 19:46:42.869 20565-20594/com.myapp.www A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 20594 (RenderThread)
[ 07-24 19:46:42.870 2316: 2316 W/ ]
debuggerd: handling request: pid=20565 uid=10192 gid=10192 tid=20594
I am using Picasso to load the images from the URL provided by a reference to Firebase Storage. This method works fine for me on the Le Eco device.
I tried setting android:hardwareAccelerated=false and android:largeHeap=true in AndroidManifest.xml according to some answers here. It works, but it is making the app very jittery, which defeats the purpose of having a smooth app. Plus, if it's running on my other device, then the problem should be something else, right?
The images stored in Firebase are rescaled to 300x300 and compressed before uploading and are less than 10kb in size, so the "Bitmap too large to be uploaded" error makes absolutely no sense.
Edit: Here is the XML layout of the cardview used in the RecyclerView:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="48dp"
cardview:cardCornerRadius="4dp"
cardview:cardElevation="4dp">
<include layout="@layout/post_shimmer"/>
<include layout="@layout/image_shimmer"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/user_image_recycle"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:clickable="true"
/>
<TextView
android:id="@+id/post_type_recycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_toRightOf="@+id/user_image_recycle"
android:textStyle="italic" />
<TextView
android:id="@+id/post_title_recycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/post_type_recycle"
android:layout_marginStart="16dp"
android:layout_toRightOf="@+id/user_image_recycle"
android:maxLines="1"
android:textColor="@android:color/black"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/user_name_recycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/post_title_recycle"
android:layout_marginStart="16dp"
android:layout_toRightOf="@+id/user_image_recycle"
android:textColor="#0094BD"
android:clickable="true"
android:textSize="16sp" />
<ImageView
android:id="@+id/post_divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@+id/user_image_recycle"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:background="@android:color/black" />
<!-- It is CRUCIAL to keep the layout width to wrap_content otherwise
the text will not be selectable after Suggest change has been clicked
on once. This is an Android bug.
-->
<TextView
android:id="@+id/post_text_recycle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/post_divider"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:autoLink="web"
android:fontFamily="serif"
android:textColor="@android:color/black"
android:textColorHighlight="@android:color/holo_blue_light"
android:textIsSelectable="true"
android:textSize="16sp" />
</RelativeLayout>
</android.support.v7.widget.CardView>
</ScrollView>
</RelativeLayout>
Here is code in the onBindViewHolder method where I am using Picasso to set the ImageView:
final StorageReference imageRef = storageReference.child("images/" + uid).child("profile");
imageRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Picasso.get().load(uri)
.noFade()
.into(holder.profile, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
holder.profile.setImageDrawable(getResources().getDrawable(R.drawable.profile, null));
}
});
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
holder.profile.setImageDrawable(getResources().getDrawable(R.drawable.profile, null));
}
});
Edit 2: I removed all Picasso references from the app. It is still crashing. I am literally not loading any Bitmaps anywhere else in the app. How is this possible?
I've been trying to resolve this for four hours now and I can't seem to find any appropriate solution.
Thanks for your help!
The hardwareaccelerated=false
solution was always going to work, however, it was slowing down my app a lot.
I managed to find a local fix from this documentation:
Basically, I set hardware acceleration off only for my CircleImageView in the ViewHolder. Here's the code:
private PostViewHolder(View itemView) {
super(itemView);
profile = (CircleImageView) itemView.findViewById(R.id.user_image_recycle);
profile.setLayerType(View.LAYER_TYPE_SOFTWARE,null);
}
profile.setLayerType(View.LAYER_TYPE_SOFTWARE,null)
allows hardware acceleration to be turned off for the image only. Everything else works fine after this. The view is still slightly jittery, but not very noticeable. The images load! Yay!