Skip to content
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

Prevent NPE in ImageLayer.getBounds() #2578

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ public class ImageLayer extends BaseLayer {
if (lottieDrawable.getMaintainOriginalImageBounds()) {
outBounds.set(0, 0, lottieImageAsset.getWidth() * scale, lottieImageAsset.getHeight() * scale);
} else {
outBounds.set(0, 0, getBitmap().getWidth() * scale, getBitmap().getHeight() * scale);
Bitmap bitmap = getBitmap();
if (bitmap != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if this is null? Will outBounds potentially have a stale value from another frame?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gpeal I don't have the full context here so maybe @geomaster can chime in on what scenarios would cause the bitmap to be null and whether we need alternate behavior around updating outBounds.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I'm not sure why the bitmap would be null - presumably, it has not loaded yet, or it didn't load correctly?

If the bitmap is null, we would be rendering nothing, so I think arguably the correct thing to do is simply to set to an empty rectangle, with outBounds.set(0, 0, 0, 0).

Thoughts?

outBounds.set(0, 0, bitmap.getWidth() * scale, bitmap.getHeight() * scale);
}
}
boundsMatrix.mapRect(outBounds);
}
Expand Down
Loading