Status Update
Comments
ub...@gmail.com <ub...@gmail.com> #2
ba...@gmail.com <ba...@gmail.com> #3
If the width or height is greater than 8191, left-shifting causes the sign bit to be lost, turning a '1' into a '0', which results in an incorrect width or height.
I agree there's a bug here, but I'm not sure this is quite a precise description of the problem. A quick experiment suggests that the left shift (<<
) works fine (if we are just looking at bits), but the right shift (>>
) is where the problem is introduced, because >>
does "sign extension" in Java - meaning if input value is negative (the MSB of the 32-bit int is 1
), then the result will be negative too. This can be fixed by using the unsigned right shift operator (>>>
).
You can see this in jshell
:
$ jshell
| Welcome to JShell -- Version 22
| For an introduction type: /help intro
jshell> int width = 5
width ==> 5
jshell> int height = 8192
height ==> 8192
jshell> int widthAndHeight = (width << 16) | height
widthAndHeight ==> 335872
jshell> (widthAndHeight << 18) >> 18
$8 ==> -8192
jshell> (widthAndHeight << 18) >>> 18
$9 ==> 8192
That said, I also agree that your change in
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #4
Thanks for your reply. So it it ok to be merged?
il...@google.com <il...@google.com> #5
Branch: androidx-main
commit 59e5677498b92689c2c92801c1f371f24ca7024e
Author: Ian Baker <ibaker@google.com>
Date: Thu Aug 01 16:12:27 2024
Add a test WebP image with a height of 8192px
This exercises the bug reported in
The test is disabled for now. It can be enabled as part of merging the
fix in
This image was generated using imagemagick:
$ convert webp_without_exif.webp \
-resize 6144x8192 \
webp_without_exif_height_8192px.webp
Bug: 342697059
Test: ExifInterfaceTest
Change-Id: Ib014f54fbe8d28579f95d5d2f34e302cdd569fb9
M exifinterface/exifinterface/src/androidTest/java/androidx/exifinterface/media/ExifInterfaceTest.java
A exifinterface/exifinterface/src/androidTest/res/raw/webp_without_exif_height_8192px.webp
Description
Version used: 1.1.0
Devices/Android versions reproduced on: Emulator API 19
Activity.reportFullyDrawn() was introduced in API 19 but has a bug at that API level requiring the system permission UPDATE_DEVICE_STATS, which is not available to non-system apps. FragmentActivity could override the method and do nothing on API 19 and below. This avoids running into the unfixable bug, and also avoids having to do API-specific code wrapping for API 18 and below where the method does not exist.