-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[Crash] RCTImageBlurUtils.m BlurRadius Crash #35706
Comments
Following up here as this is pretty serious and reproducible crash that occurs on our production apps. |
Good day to everyone. We are also having the same issue on our production app with version RN 0.70.6. any suggestions ? |
This seems to be a pretty serious issue causing a full kernel panic. Would be great if someone can chime in! |
Faced with the same error, RN 0.71.1, old Arch, Hermes enabled |
I've the same issue ☝️ (blurRadius + black and white image cause a crash) RN 0.70.7 / hermes enabled Edit: Actually on my side it seems to only happen in dev mode. |
Yes it seems to happen for images that don't have enough color information. Black / White / Grey all cause crashes. This is really bad as quite a lot of users are impacted by this. Would be great if someone from the React Native team can chime in here! |
Same issue here, started seeing this recently (probably have not seen this before just because it only happens for certain images). RN 0.70.5 / hermes enabled, old arch, production app |
Pretty serious issue... would be grateful if someone can look into this! 🙌🏼 |
We can also reproduce the issue on production: RN 0.71.6 / hermes enabled |
@matrush @sammy-SC @steveccable Sorry for tagging you here, but this is a pretty serious kernel crash, and I saw that the three of you previously fixed major issues with this function. Would really appreciate it you can have a look 🙏🏼 |
Hey everyone, I actually figured out what's causing this crash and created a PR with more context. The fix is very simple, and you can apply it via a patch to your existing apps until the PR is merged and you update React Native. Here is the PR to see the one-line change: #37508 |
Summary: ## 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 Pull Request resolved: #37508 Test Plan: ``` <ImageBackground blurRadius={18} source={{uri: 'https://i.scdn.co/image/ab67616d0000b2737663b2f75fe4d8fb2cac8c27'}} /> <ImageBackground blurRadius={5} source={{uri: 'https://i.scdn.co/image/ab67616d0000b273d5a219b270d74a266131df18'}} /> `` Reviewed By: NickGerleman Differential Revision: D46071330 Pulled By: javache fbshipit-source-id: 8c04cbf88d467596c9c8a9de9a380bc10663a0e5
Fix has been merged! |
Unfortunately this fix does not seem to reliably resolve the crashes. I created a second PR that addresses the issue: |
Hello @OskarEichler, I would like to take a closer look at this but I can't reproduce the crash with your test plan. Is there anything I missed in test plan or is just just rendering those two images? |
@sammy-SC Yes correct, applying a blur-radius on those two images causes an immediate crash because the ARGB method can't handle the image. First I was under the impression that it was due to greyscaled images being excluded from the previous step of being converted to ARGB, which is why I opened the following PR: #37508 However, it turned out that they still caused a crash, possibly because of the new UIGraphicsImageRenderer not properly aligning the bitmap data. I opted to reverse back to the older UIGraphicsBeginImageContextWithOptions which works reliably, however might be a bit slower as the API is older: #37546 There could be a path to use the newer UIGraphicsImageRenderer, however as the new API does not provide a lot of customizability it would involve writing more code and dealing with additional complexity, particularly when dealing with memory management in order to manually ensure that the buffer is properly formatted and aligned. Are you able to reproduce the crash on your side when blurring the images? |
@OskarEichler I actually can't reproduce it. I have tried simulator and device both debug and production builds. |
@sammy-SC Maybe check if you can reproduce it based on what someone else experienced here: https://snack.expo.dev/@saurabhkanswalquizizz/imagebackground-blurradius |
@OskarEichler |
@OskarEichler on the screenshot on the first message on this issue, what is value of My current theory is that it is 0. Calling malloc with 0 is legal but calling |
@sammy-SC Just ran it again - right now it's only happening when building to physical device. Please find all of the info below, and let me know if you need anything else. Error: Thread 32: EXC_BAD_ACCESS (code=1, address=0x1472a0438) Debug Info:
|
@sammy-SC If this is not helpful, please let me know how I can export more helpful logs for you! 🙏🏼 |
@OskarEichler thank you for providing the extra information. |
I can still reproduce the crash, in the simulator even with this fix applied, with this image and |
Is this issue fixed in future React Native versions since this thread went stale? |
Description
We are having an issue with RCTImageBlurUtils.m causing a Kernel crash for some images.
The images we identified are all pretty minimal (black and white, with a lot of black pixels). Not sure if this is related and the blur algorithm simply doesn't have enough information to go by, for most other images everything works normal.
I attached some of the images that are causing the crash below. We tried both a blurRadius of 5, as well as 18. Behavior is the same and it always results in a crash:
Thread 3: EXC_BAD_ACCESS (code=1, address=0x13d54c4c8)
Version
0.70.6
Output of
npx react-native info
System:
OS: macOS 13.1
CPU: (10) arm64 Apple M1 Max
Memory: 7.53 GB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.14.0 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.19.2 - ~/trackstats/node_modules/.bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.3 - /Users/Oskar/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9123335
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 17.0.3.1 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: ^18.2.0 => 18.2.0
react-native: ^0.70.6 => 0.70.6
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
Both of those images are crashing the application for us (potentially because they are mostly black?)
Snack, code example, screenshot, or link to a repository
crash-log.txt
The text was updated successfully, but these errors were encountered: