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

[Fabric] Support blob: images, and provide better image.onError callbacks #13285

Merged
merged 13 commits into from
Jun 4, 2024

Conversation

acoates-ms
Copy link
Contributor

@acoates-ms acoates-ms commented May 30, 2024

Description

In a recent integration ImageLoader started taking more detailed error information. This change provides better error handling for image loading.

I also went ahead and hooked up an ImageLoader for blob: images.

Recent changes to the ImageExample RNTester test page added uses of an Image uri which requires a user-agent header be included in the request to successfully download the image. This PR adds a new API Microsoft.ReactNative.Networking.SetDefaultUserAgent(ReactInstanceSettings, string) which applications can use to set the a default user-agent header for network requests.

The new ImageExample images also needed work to get to work in paper. In particular piping through the new DefaultUserAgent, and forcing a custom download step if its set.

Fixes #13262.

Microsoft Reviewers: Open in CodeFlow

@acoates-ms acoates-ms added the Area: Fabric Support Facebook Fabric label May 30, 2024
@acoates-ms acoates-ms requested review from a team as code owners May 30, 2024 19:28
@microsoft-github-policy-service microsoft-github-policy-service bot added the New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric label May 30, 2024
-> winrt::Microsoft::ReactNative::Composition::Experimental::IBrush {
auto compositor = winrt::Microsoft::ReactNative::Composition::Experimental::
MicrosoftCompositionContextHelper::InnerCompositor(compositionContext);
auto drawingBrush = compositionContext.CreateDrawingSurfaceBrush(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: {} - brace initialization to avoid any type conversion happening and ensuring uniform initialization? https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es23-prefer-the--initializer-syntax

winrt::Windows::Graphics::DirectX::DirectXAlphaMode::Premultiplied);
POINT pt;
Microsoft::ReactNative::Composition::AutoDrawDrawingSurface autoDraw(drawingBrush, scale, &pt);
auto renderTarget = autoDraw.GetRenderTarget();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: uniform initialization?

size,
winrt::Windows::Graphics::DirectX::DirectXPixelFormat::B8G8R8A8UIntNormalized,
winrt::Windows::Graphics::DirectX::DirectXAlphaMode::Premultiplied);
POINT pt;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

POINT pt{}?

const winrt::Microsoft::ReactNative::IReactContext &reactContext,
const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compositionContext)
-> winrt::Microsoft::ReactNative::Composition::Experimental::IBrush {
auto compositor = winrt::Microsoft::ReactNative::Composition::Experimental::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uniform initialization?

@acoates-ms acoates-ms requested review from a team as code owners May 31, 2024 20:23
@acoates-ms acoates-ms merged commit adc4d09 into microsoft:main Jun 4, 2024
53 checks passed
@acoates-ms acoates-ms deleted the imgFailedAndBlobs branch June 4, 2024 00:15
acoates-ms added a commit to acoates-ms/react-native-windows that referenced this pull request Jun 4, 2024
…acks (microsoft#13285)

* [Fabric] Support blob: images, and provide better image.onError callbacks

* Change files

* Remove some test code

* Add user-agent

* Add public API to set default User-Agent header

* various fixes

* fix snapshots

* Rename Networking -> HttpSettings

* Change files

* fix

* Http.UserAgent RuntimeOption needs to be set before the HttpResource is created
acoates-ms added a commit that referenced this pull request Jun 5, 2024
* [Fabric] Support blob: images, and provide better image.onError callbacks (#13285)

* [Fabric] Support blob: images, and provide better image.onError callbacks

* Change files

* Remove some test code

* Add user-agent

* Add public API to set default User-Agent header

* various fixes

* fix snapshots

* Rename Networking -> HttpSettings

* Change files

* fix

* Http.UserAgent RuntimeOption needs to be set before the HttpResource is created

* fixups for ImageErrorInfo not existing in 0.74

* fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Fabric Support Facebook Fabric New Architecture Broad category for issues that apply to the RN "new" architecture of Turbo Modules + Fabric
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Fabric] Pipe through ImageLoadError and ImageErrorInfo data
4 participants