-
Notifications
You must be signed in to change notification settings - Fork 1
Capture SDK: Crash fix related to bitmap (PM-150) #711
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
base: main
Are you sure you want to change the base?
Conversation
…is null for any reason. PM-150
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a crash related to bitmap handling in the PhotoThumbnail class by adding null safety checks to prevent NullPointerException when working with bitmap objects.
- Added null check for bitmap before accessing bitmap properties in rotation logic
- Improved null safety in the setBitmapOrBlack method by extracting bitmap reference
@Nullable final ThumbnailBitmap stackBitmap) { | ||
if (stackBitmap != null) { | ||
imageView.setImageBitmap(stackBitmap.getRotatedBitmap()); | ||
Bitmap bitmap = (stackBitmap != null) ? stackBitmap.getRotatedBitmap() : null; |
Copilot
AI
Jul 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change introduces a potential issue where getRotatedBitmap() could return null (if the underlying bitmap is null), but the original logic assumed it would always return a valid bitmap when stackBitmap is not null. The null check should be performed after calling getRotatedBitmap() to handle cases where the method returns null.
Copilot uses AI. Check for mistakes.
Matrix matrix = new Matrix(); | ||
matrix.postRotate(rotation); | ||
rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); |
Copilot
AI
Jul 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The null check for bitmap should be performed before calling bitmap.getWidth() and bitmap.getHeight() on line 139. If bitmap becomes null between this check and the createBitmap call, it will still cause a NullPointerException.
Matrix matrix = new Matrix(); | |
matrix.postRotate(rotation); | |
rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); | |
Bitmap localBitmap = bitmap; // Store a local reference to ensure consistency | |
Matrix matrix = new Matrix(); | |
matrix.postRotate(rotation); | |
rotatedBitmap = Bitmap.createBitmap(localBitmap, 0, 0, localBitmap.getWidth(), localBitmap.getHeight(), matrix, true); |
Copilot uses AI. Check for mistakes.
PM-150