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

[IOS] [FIXED] Fix RCTImageBlurUtils.m Greyscale Crash #37508

Closed
wants to merge 1 commit into from

Conversation

OskarEichler
Copy link
Contributor

@OskarEichler OskarEichler commented May 22, 2023

Summary:

This PR fixes a kernel crash caused by trying to blur greyscale images, as described in this issue:
#35706 (comment)

Context:

The CGImageGetBitsPerPixel(imageRef) == 8 expression checks if each pixel of the image is represented by 8 bits.

In an image, each pixel is typically represented by a certain amount of information to store its color. In a grayscale image, for instance, we often use 8 bits per pixel, which allows for 256 different shades of gray (2^8 = 256).

The function vImageBoxConvolve_ARGB8888 works with ARGB images (which stands for Alpha, Red, Green, Blue). If the image is only black & white, it means it's a grayscale image, and hence, it is not compatible with this function, causing the kernel crash.

To prevent the issue, we should also convert grayscale images to ARGB before processing them.

Changelog:

[IOS] [FIXED] - Fix RCTImageBlurUtils.m Greyscale Crash

Test Plan:

<ImageBackground
        blurRadius={18}
        source={{uri: 'https://i.scdn.co/image/ab67616d0000b2737663b2f75fe4d8fb2cac8c27'}}
/>

<ImageBackground
        blurRadius={5}
        source={{uri: 'https://i.scdn.co/image/ab67616d0000b273d5a219b270d74a266131df18'}}
/>
``

@facebook-github-bot
Copy link
Contributor

Hi @OskarEichler!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,733,284 +4
android hermes armeabi-v7a 8,044,465 +4
android hermes x86 9,223,386 +2
android hermes x86_64 9,075,374 +1
android jsc arm64-v8a 9,298,080 +2
android jsc armeabi-v7a 8,486,818 +2
android jsc x86 9,359,244 +1
android jsc x86_64 9,615,339 +3

Base commit: 6d24ee1
Branch: main

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 22, 2023
@Pranav-yadav
Copy link
Contributor

Hi @OskarEichler, 👋

Congratulations 🎉 on your "First Pull Request" to React Native! 🥳

Thank you, 🙏 for taking the time to contribute to this project and share your ideas.

Someone from the team will review your PR and get back to you as soon as possible with feedback if any. 😊 Post review, and if all tests are passing, your PR will be imported to internal FB phabricator and should be merged if it also passes all internal tests. 🥳

P.S.: In the meantime, you should go through below checklist: (click to expand)
  1. Make sure you have signed the CLA 📃🙂,
  2. There are no typos 😄,
  3. All tests 🧪 are passing. i.e. The CI checks should be green 🟢, and
  4. You have added necessary tests for your code, if it's a refactor or a new functionality. 🧪

Contributing Guidelines | React Native Website | Framework discussions, proposals and RFCs

@facebook-github-bot
Copy link
Contributor

@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@cortinico cortinico requested a review from sammy-SC May 22, 2023 20:28
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 23, 2023
@facebook-github-bot
Copy link
Contributor

@javache merged this pull request in d6c4f27.

@OskarEichler
Copy link
Contributor Author

Unfortunately this fix does not seem to reliably resolve the crashes. I created a second PR that addresses the issue:
#37546

@raid5
Copy link

raid5 commented Oct 8, 2024

The 2nd PR was never merged, so I'm assuming the first fix is sufficient? I have an app on RxN 0.72.10 and it looks like the initial fix is included in 0.73+, correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: Image Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants