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

RCTUIImageViewAnimated incompatible with iOS 14 #29268

Closed
mo22 opened this issue Jul 2, 2020 · 16 comments
Closed

RCTUIImageViewAnimated incompatible with iOS 14 #29268

mo22 opened this issue Jul 2, 2020 · 16 comments
Labels
API: Animated Component: Image Needs: Triage 🔍 Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@mo22
Copy link

mo22 commented Jul 2, 2020

Images do not render on iOS 14 beta devices

Please see SDWebImage/SDWebImage#3040 for a discussion.

Looks as if [super displayLayer] needs to be called manually now.

- (void)displayLayer:(CALayer *)layer

#pragma mark - CALayerDelegate

- (void)displayLayer:(CALayer *)layer
{
  if (_currentFrame) {
    layer.contentsScale = self.animatedImageScale;
    layer.contents = (__bridge id)_currentFrame.CGImage;
  } else {
    [super displayLayer:layer]; // this here!
  }
}

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

Please provide a clear and concise description of what the bug is. Include screenshots if needed.
Please test using the latest React Native release to make sure your issue has not already been fixed: https://reactnative.dev/docs/upgrading.html

React Native version:

Run react-native info in your terminal and copy the results here.

System:
OS: macOS 10.15.5
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Memory: 3.83 GB / 32.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 14.5.0 - /usr/local/bin/node
Yarn: Not Found
npm: 6.14.5 - /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.5, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK:
API Levels: 27, 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-24 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6514223
Xcode: 11.5/11E608c - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_232 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: ^4.10.1 => 4.10.1
react: ^16.13.0 => 16.13.1
react-native: ^0.62.2 => 0.62.2
npmGlobalPackages:
react-native: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

Expected Results

Describe what you expected to happen.

Snack, code example, screenshot, or link to a repository:

Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem.
You may provide a screenshot of the application if you think it is relevant to your bug report.
Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

@zi6xuan
Copy link

zi6xuan commented Jul 9, 2020

i found the same issue

@hramos hramos added the iOS 14 label Jul 9, 2020
@mo22
Copy link
Author

mo22 commented Jul 10, 2020

proper fix (so that for example react-native-video also works) would be this (calling super displayLayer always):

#pragma mark - CALayerDelegate

- (void)displayLayer:(CALayer *)layer
{
  if (_currentFrame) {
    layer.contentsScale = self.animatedImageScale;
    layer.contents = (__bridge id)_currentFrame.CGImage;
  }
  [super displayLayer:layer]; // this here!
}

@keremoge
Copy link

keremoge commented Jul 17, 2020

Should we wait for 0.63.2? or just manually fix it?

@igoriols
Copy link

Hello, there is a way to solve it without updating to 0.63.x?

bweissbart added a commit to bweissbart/flagship that referenced this issue Aug 5, 2020
This adds a script to iOS init that patches RCTUIImageViewAnimated.m to display images in iOS 14.

See issue here: facebook/react-native#29268
bweissbart added a commit to bweissbart/flagship that referenced this issue Sep 14, 2020
This adds a script to iOS init that patches RCTUIImageViewAnimated.m to display images in iOS 14.

See issue here: facebook/react-native#29268
bweissbart added a commit to bweissbart/flagship that referenced this issue Sep 14, 2020
This adds a script to iOS init that patches RCTUIImageViewAnimated.m to display images in iOS 14.

See issue here: facebook/react-native#29268
@imhuy
Copy link

imhuy commented Sep 25, 2020

@helderberto
Copy link

helderberto commented Sep 28, 2020

All the shells and script files I organize into scripts directory.

I made the following steps to fix:

  1. Create a file scripts/fix_images_ios_14.sh;
  2. Define the following code:
#!/usr/bin/env bash
echo "🔨️ Fixing Images..."
HUYDEV="_currentFrame.CGImage;"
HUYFIX="_currentFrame.CGImage ;} else { [super displayLayer:layer];"
sed -ie "s/${HUYDEV}/${HUYFIX}/" node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m
echo "✅ Images has been fixed!"
  1. Add script postinstall to package.json i.e: "postinstall": "sh ./scripts/fix_images_ios_14.sh";
  2. Remove node_modules and install packages again with yarn/npm.

@mo22
Copy link
Author

mo22 commented Sep 28, 2020

  1. Add script postinstall to package.json i.e: "postinstall": "sh ./scripts/fix_images_ios_14.sh";
  2. Remove node_modules and install packages again with yarn/npm.

https://github.com/ds300/patch-package is a good solution for that

@Raksha21
Copy link

  1. "postinstall": "sh ./scripts/fix_images_ios_14.sh";

Its not working on my system Xcode v12 and iOS14

@helderberto
Copy link

helderberto commented Oct 2, 2020

React Native v0.61.4


Updated version with patch-package

  1. Install patch-package into your project patch-package
  2. Add to your package.json in scripts: "postinstall": "patch-package"
  3. Create directory patches and the file react-native+0.61.4.patch inside of it on your root project directory:
diff --git a/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m b/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m
index 01aa75f..0337ef1 100644
--- a/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m
+++ b/node_modules/react-native/Libraries/Image/RCTUIImageViewAnimated.m
@@ -266,9 +266,11 @@ - (void)displayDidRefresh:(CADisplayLink *)displayLink
 
 - (void)displayLayer:(CALayer *)layer
 {
-  if (_currentFrame) {
+ if (_currentFrame) {
     layer.contentsScale = self.animatedImageScale;
     layer.contents = (__bridge id)_currentFrame.CGImage;
+  } else {
+    [super displayLayer:layer];
   }
 }
  1. Remove your node_modules and install the packages again.

@roycechua
Copy link

You can also try running these commands to install the patch

patch -p1 -i patches/react-native+0.61.4.patch
npx patch-package react-native

@saadnaveed94
Copy link

Still facing the issue in react-native 0.64.2

@Raksha21
Copy link

Raksha21 commented Nov 25, 2021 via email

@bogdansimon-rebeldot
Copy link

Hi Raksha21, in which version was this error fixed? I still experience it with react-native 0.66.3

@saadnaveed94
Copy link

saadnaveed94 commented Nov 25, 2021

Hi @Raksha21 @bogdansimon. i fixed it by adding this script in package.json. it uses this package. https://github.com/imhuy/react-native-fix-image
"postinstall": "npx react-native-fix-image"

crherman7 pushed a commit to crherman7/flagship that referenced this issue Nov 14, 2022
This adds a script to iOS init that patches RCTUIImageViewAnimated.m to display images in iOS 14.

See issue here: facebook/react-native#29268

brandingbrand-source-id: 19a026e64676316488cf26fe19d52ec80d77ee4b
crherman7 pushed a commit to crherman7/flagship that referenced this issue Nov 14, 2022
This adds a script to iOS init that patches RCTUIImageViewAnimated.m to display images in iOS 14.

See issue here: facebook/react-native#29268

brandingbrand-source-id: 06c4d2ac99713d90b2c9612eb413e88e81b335d4
@kelset kelset removed the iOS 14 label Jan 23, 2023
@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 23, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: Animated Component: Image Needs: Triage 🔍 Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests