Fresco: roundingBorderColor cause the placeholder image display error

Created on 19 Jul 2018  路  5Comments  路  Source: facebook/fresco

<com.facebook.drawee.view.SimpleDraweeView
        android:layout_below="@id/button"
        android:id="@+id/simple"
        android:layout_centerHorizontal="true"
        android:layout_width="match_parent"
        android:layout_height="600px"
        fresco:placeholderImage="@drawable/logo"
        fresco:roundingBorderWidth="10px"
        fresco:roundingBorderColor="@color/image_detail_help_background" />

then

qq20180719-1

  • Fresco version: all version
  • Platform version:all devices
bug help wanted

All 5 comments

Hi @TongWeiLe

Thanks for reporting this issue. I'm able to reproduce it, also when setting the border in the RoundingParams in the code. We might take a look on that in the future but if you have any idea on how to fix it in the meantime, feel free to submit a pull request.

Also, if you disable placeholder rounding using your PR https://github.com/facebook/fresco/pull/2158, does this still reproduce?

This issue is caused by Android's bitmap shaders as explained in the rounding section here: http://frescolib.org/docs/rounded-corners-and-circles.html.

Borders are meant to be used in conjunction with rounding (as their name suggest) and for drawing a normal border, you can just create a simple overlay that draws on top of the image. It will also be more efficient since you don't need all the rounding logic for square images. If you must use our rounding parameters to draw the border, it works if you use the overlay color rounding mode as described in our docs.

Related issues & more suggestions: #1588, #751, #605 and the original one: #555

that's can be fixed by both set roundingBorderColor & roundWithOverlayColor,read the source code ,I found
it's a RoundedCornersDrawable and set the bordercolor by

if (mBorderColor != Color.TRANSPARENT) {
      mPaint.setStyle(Paint.Style.STROKE);
      mPaint.setColor(mBorderColor);
      mPaint.setStrokeWidth(mBorderWidth);
      mPath.setFillType(Path.FillType.EVEN_ODD);
      canvas.drawPath(mBorderPath, mPaint);
    }

meantime,I read the doc found this

since it simulates rounded corners by overlaying a solid color over the image

so when our app have lot's of simpleDraweeView and all set border line ,this will increase our app memory usage? @oprisnik

@zmroczek if you disable placeholder rounding, will not reproduce this issue

It's both a CPU and (smaller) memory overhead yes since you tell Fresco to round the image with 0dp and draw a border, which means we need to account for that. I've outlined a couple alternatives above that should be (a bit) more efficient.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eldk picture eldk  路  3Comments

liubaoyua picture liubaoyua  路  3Comments

stevenmtang picture stevenmtang  路  3Comments

hanhmh1203 picture hanhmh1203  路  4Comments

ykostova picture ykostova  路  3Comments