-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Assets uri's that begin with ph:// cause error #36136
Comments
As this is related to |
You don’t have to use |
Could you please reopen this @cortinico? I boiled it down to something simpler to show that it is a react native issue, and not an running the following code fails on the new architecture:
but it runs exactly as expected in the old one. It looks like the new architecture can not handle iOS's I will update the original issue to make it clearer. Thanks! |
please save me!!!!! |
for any one who needs a temporary workaround, I found that expo's image component works with cc @mingyeom1 |
any update or ideas around what might cause this bug? I've been using |
What does the |
Just mean that the URI starts with That issue with permissions was just an The problem here is that React Native's core EDIT: To clarify, the user does need to grant either limited or full access to photo library to render a photo library image, but that is not the main issue here |
linking to where the error is being triggered: code |
maybe we can override getModuleInstanceFromClass in AppDelegate to add |
Sharing some findings and a solution that worked for me: FindingsAccording to this issue React Native no longer support's SolutionUltimetly, I was able to work around this by:
Extra InfoAfter these finding's I realized the reason |
Hi @norbusonam, thank you for opening the issue and to explore it further. We are aware of this limitation for the new Architecture, unfortunately. I see you found the PR trying to fix that, but we are not convinced by that fix yet. Your override is a good workaround for the time being, while we find a better solution. |
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. |
up, we don't want for this issue to be reaped. We will work on this next half. |
I'm looking into this. I was not around when the old architecture was the only architecture... As far as I can see, we always relied on 3rd party libraries to load I'm trying to understand what's the expectation for a react native project with no libraries. Perhaps @tsapeta, @WoLewicki or @mrousavy knows something about this? How was React Native behaving in the Old Architecture? Has it ever worked with |
I remember |
I think it did work previously. We were using it in our examples for After a quick look, I'm not actually sure why 😅 Rendering them would require using the Maybe the URL loader somehow supported it and treated as a network request?
It's definitely not the case. This loader doesn't do anything beyond what RN's loaders support and we can actually remove it as it's no longer used. |
@norbusonam @mrousavy @tsapeta Repro:
I retrieved the ID by:
#import <Photos/PHAsset.h>
//...
PHFetchResult<PHAsset *> * res = [PHAsset fetchAssetsWithOptions:nil];
PHAsset * first = res.firstObject;
NSLog(@"Id: %@", first.localIdentifier); Then, replace the App.tsx content with the following: import React from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
useColorScheme,
Image,
View,
} from 'react-native';
import {Colors} from 'react-native/Libraries/NewAppScreen';
function App(): JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Image
source={{uri: 'ph://106E99A1-4F6A-45A2-B320-B0AD4A8E8473'}}
style={{width: 100, height: 100}}
/>
</View>
</ScrollView>
</SafeAreaView>
);
}
export default App; For my simulator, When I run the app in the Old Architecture, I get the same error message: Could it be that, in the Old Architecture, the libraries were able to self register their image handler in the list of handlers?
And it looked like React Native is able to manage the That fits with my understanding and as a difference between New/Old Arch. In fact, libraries couldn't, before 0.74, register themselves as URL Handlers/Image Loaders in the New Architecture. |
Closing this as it is an intended React Native behaviour. The Old Architecture is relying on some library to pick up the In the New Architecture, before 0.74, libraries could not register themselves as URL handler, hence, this issue has been opened. In 0.74, thanks to this PR, libraries can now register themselves as URL handler, filling the gap between the Old and the New architecture. |
Hey @cipolleschi - this makes perfect sense, thanks for the explanation. I'm not sure if I understand how to properly register custom image loaders (or URL handlers) now on the new architecture though? Is there a method I can use to register a custom handler in my AppDelegate? RN CameraRoll still has that custom PH asset handler, but it doesn't work anymore. see react-native-cameraroll/react-native-cameraroll#631 |
@mrousavy I found this conversation: #36071 (comment). Seems like for some reason the links to commits are broken and lead to some weird, non-connected ones. I can quickly try to find the exact commit that introduces the changes @cipolleschi mentioned. |
Looks like it is this one: #42923 |
Got it! For everyone else stumbling upon this issue, here's what I did:
Install pods & rebuild, and now the @WoLewicki I'll create a PR to CameraRoll :) |
@cortinico two things I wanna note here;
|
Ah - |
I just created a PR in react-native-cameraroll to add custom Image URL loaders for So if you install react-native-cameraroll, |
What is the fix for Just as a context, I am using the default |
+1 |
Expo's image library is compatible with You can also get the local URI of an asset by doing |
It turned out we had a regression causing the |
I am using But I found workaround as well. As #36136 (comment) says, I left the workaround / error in my repo as well. Hopefully it helps someone |
Hey folks, if anyone comes here on the new architecture, I just opened up expo/expo#33097, which I think might fix your issues once merged and shipped. |
Description
When giving the
Image
component auri
beginning withph://
like so:the image fails to render:
In my scenario, I used
expo-media-library
to retrieve the uri's. I built my app with the old architecture, and this error did not persist.Version
0.71.1
Output of
npx react-native info
System:
OS: macOS 13.2
CPU: (8) arm64 Apple M1
Memory: 75.11 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.13.0/bin/yarn
npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm
Watchman: 2023.01.30.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/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: Not Found
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: Not Found
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.1 => 0.71.1
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Steps to reproduce
ph://
by any meansSnack, code example, screenshot, or link to a repository
Not sure how to switch a snack into the new architecture, but this code in the new architecture will fail:
https://snack.expo.dev/gv6bMd2MY?platform=ios
UPDATE: Providing a simpler example to convey that this is a react native issue and not due to any dependency. The following code fails on the new archatecure with the error above:
but it runs exactly as expected in the old one. It looks like the new architecture can not handle iOS's ph:// routes.
The text was updated successfully, but these errors were encountered: