mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Remove unused Fabric image instrumentation
Summary: Remove the older implementation of image instrumentation in Fabric by removing, RCTImageInstrumentationProxy, ImageInstrumentation from ImageRequest, and trackURLImageContentDidSetForRequest from RCTImageLoaderWithAttributionProtocol. Changelog: [RN][Fabric][Image] Remove unused Fabric image instrumentation Reviewed By: fkgozali Differential Revision: D23990606 fbshipit-source-id: 004d04025d031af11377a73e5bfb64b1e0449962
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c06f765f7d
commit
a7c026e667
@@ -831,19 +831,6 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image,
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)trackURLImageContentDidSetForRequest:(RCTImageURLLoaderRequest *)loaderRequest
|
||||
{
|
||||
if (!loaderRequest) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This delegate method is Fabric-only
|
||||
id<RCTImageURLLoader> loadHandler = [self imageURLLoaderForURL:loaderRequest.imageURL];
|
||||
if ([loadHandler respondsToSelector:@selector(trackURLImageContentDidSetForRequest:)]) {
|
||||
[(id<RCTImageURLLoaderWithAttribution>)loadHandler trackURLImageContentDidSetForRequest:loaderRequest];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)trackURLImageVisibilityForRequest:(RCTImageURLLoaderRequest *)loaderRequest imageView:(UIView *)imageView
|
||||
{
|
||||
if (!loaderRequest || !imageView) {
|
||||
|
||||
@@ -36,11 +36,6 @@ RCT_EXTERN void RCTEnableImageLoadingPerfInstrumentation(BOOL enabled);
|
||||
completionBlock:(RCTImageLoaderCompletionBlockWithMetadata)completionBlock;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Image instrumentation - notify that the image content (UIImage) has been set on the native view.
|
||||
*/
|
||||
- (void)trackURLImageContentDidSetForRequest:(RCTImageURLLoaderRequest *)loaderRequest;
|
||||
|
||||
/**
|
||||
* Image instrumentation - start tracking the on-screen visibility of the native image view.
|
||||
*/
|
||||
|
||||
@@ -59,11 +59,6 @@ struct ImageURLLoaderAttribution {
|
||||
completionHandler:(RCTImageLoaderCompletionBlockWithMetadata)completionHandler;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Image instrumentation - notify that the image content (UIImage) has been set on the native view.
|
||||
*/
|
||||
- (void)trackURLImageContentDidSetForRequest:(RCTImageURLLoaderRequest *)loaderRequest;
|
||||
|
||||
/**
|
||||
* Image instrumentation - start tracking the on-screen visibility of the native image view.
|
||||
*/
|
||||
|
||||
@@ -13,9 +13,7 @@
|
||||
#import <react/renderer/components/image/ImageComponentDescriptor.h>
|
||||
#import <react/renderer/components/image/ImageEventEmitter.h>
|
||||
#import <react/renderer/components/image/ImageProps.h>
|
||||
#import <react/renderer/imagemanager/ImageInstrumentation.h>
|
||||
#import <react/renderer/imagemanager/ImageRequest.h>
|
||||
#import <react/renderer/imagemanager/RCTImageInstrumentationProxy.h>
|
||||
#import <react/renderer/imagemanager/RCTImagePrimitivesConversions.h>
|
||||
|
||||
using namespace facebook::react;
|
||||
@@ -160,11 +158,6 @@ using namespace facebook::react;
|
||||
if (!data.hasValue()) {
|
||||
return;
|
||||
}
|
||||
auto instrumentation = std::static_pointer_cast<RCTImageInstrumentationProxy const>(
|
||||
data.value().getImageRequest().getSharedImageInstrumentation());
|
||||
if (instrumentation) {
|
||||
instrumentation->didSetImage();
|
||||
}
|
||||
};
|
||||
|
||||
if (imageProps.blurRadius > __FLT_EPSILON__) {
|
||||
|
||||
@@ -46,7 +46,7 @@ class ImageShadowNode final : public ConcreteViewShadowNode<
|
||||
ShadowNodeFamilyFragment const &familyFragment,
|
||||
ComponentDescriptor const &componentDescriptor) {
|
||||
auto imageSource = ImageSource{ImageSource::Type::Invalid};
|
||||
return {imageSource, {imageSource, nullptr, nullptr}, 0};
|
||||
return {imageSource, {imageSource, nullptr}, 0};
|
||||
}
|
||||
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
@@ -44,13 +44,13 @@ class SliderShadowNode final : public ConcreteViewShadowNode<
|
||||
ComponentDescriptor const &componentDescriptor) {
|
||||
auto imageSource = ImageSource{ImageSource::Type::Invalid};
|
||||
return {imageSource,
|
||||
{imageSource, nullptr, nullptr},
|
||||
{imageSource, nullptr},
|
||||
imageSource,
|
||||
{imageSource, nullptr, nullptr},
|
||||
{imageSource, nullptr},
|
||||
imageSource,
|
||||
{imageSource, nullptr, nullptr},
|
||||
{imageSource, nullptr},
|
||||
imageSource,
|
||||
{imageSource, nullptr, nullptr}};
|
||||
{imageSource, nullptr}};
|
||||
}
|
||||
|
||||
#pragma mark - LayoutableShadowNode
|
||||
|
||||
@@ -70,7 +70,6 @@ rn_xplat_cxx_library(
|
||||
ios_exported_headers = subdir_glob(
|
||||
[
|
||||
("", "*.h"),
|
||||
("platform/ios", "RCTImageInstrumentationProxy.h"),
|
||||
("platform/ios", "RCTImagePrimitivesConversions.h"),
|
||||
],
|
||||
prefix = "react/renderer/imagemanager",
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <react/renderer/core/ReactPrimitives.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
/*
|
||||
* A base class for performing image loading instrumentation.
|
||||
* The actual instrumentation is app, platform, and image loader-specific.
|
||||
*/
|
||||
class ImageInstrumentation {
|
||||
public:
|
||||
virtual ~ImageInstrumentation() noexcept = default;
|
||||
|
||||
/**
|
||||
* Mark that the image content is set on the native image component on screen.
|
||||
*/
|
||||
virtual void didSetImage() const = 0;
|
||||
|
||||
/**
|
||||
* Mark that the image view starts to be visible on screen.
|
||||
*/
|
||||
virtual void didEnterVisibilityRange() const = 0;
|
||||
|
||||
/**
|
||||
* Mark that the image view is no longer visible on screen.
|
||||
*/
|
||||
virtual void didExitVisibilityRange() const = 0;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <react/renderer/imagemanager/ImageInstrumentation.h>
|
||||
#include <react/renderer/imagemanager/ImageResponse.h>
|
||||
#include <react/renderer/imagemanager/ImageResponseObserver.h>
|
||||
#include <react/renderer/imagemanager/ImageResponseObserverCoordinator.h>
|
||||
@@ -31,8 +30,7 @@ class ImageRequest final {
|
||||
*/
|
||||
ImageRequest(
|
||||
const ImageSource &imageSource,
|
||||
std::shared_ptr<const ImageTelemetry> telemetry,
|
||||
std::shared_ptr<const ImageInstrumentation> instrumentation);
|
||||
std::shared_ptr<const ImageTelemetry> telemetry);
|
||||
|
||||
/*
|
||||
* The move constructor.
|
||||
@@ -78,20 +76,6 @@ class ImageRequest final {
|
||||
*/
|
||||
const std::shared_ptr<const ImageTelemetry> &getSharedTelemetry() const;
|
||||
|
||||
/*
|
||||
* Returns stored image instrumentation object as a shared pointer.
|
||||
* Retain this *or* `ImageRequest` to ensure a correct lifetime of the object.
|
||||
*/
|
||||
const std::shared_ptr<const ImageInstrumentation>
|
||||
&getSharedImageInstrumentation() const;
|
||||
|
||||
/*
|
||||
* Returns the image instrumentation object specific to this request.
|
||||
* Use this if a correct lifetime of the object is ensured in some other way
|
||||
* (e.g. by retaining an `ImageRequest`).
|
||||
*/
|
||||
const ImageInstrumentation &getImageInstrumentation() const;
|
||||
|
||||
private:
|
||||
/*
|
||||
* Image source associated with the request.
|
||||
@@ -108,11 +92,6 @@ class ImageRequest final {
|
||||
*/
|
||||
std::shared_ptr<const ImageResponseObserverCoordinator> coordinator_{};
|
||||
|
||||
/*
|
||||
* Image instrumentation specific to the request.
|
||||
*/
|
||||
std::shared_ptr<const ImageInstrumentation> instrumentation_;
|
||||
|
||||
/*
|
||||
* Function we can call to cancel image request (see destructor).
|
||||
*/
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ ImageRequest ImageManager::requestImage(
|
||||
const ImageSource &imageSource,
|
||||
SurfaceId surfaceId) const {
|
||||
// Not implemented.
|
||||
return ImageRequest(imageSource, nullptr, nullptr);
|
||||
return ImageRequest(imageSource, nullptr);
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
||||
+3
-18
@@ -12,19 +12,15 @@ namespace react {
|
||||
|
||||
ImageRequest::ImageRequest(
|
||||
const ImageSource &imageSource,
|
||||
std::shared_ptr<const ImageTelemetry> telemetry,
|
||||
std::shared_ptr<const ImageInstrumentation> instrumentation)
|
||||
: imageSource_(imageSource),
|
||||
telemetry_(telemetry),
|
||||
instrumentation_(instrumentation) {
|
||||
std::shared_ptr<const ImageTelemetry> telemetry)
|
||||
: imageSource_(imageSource), telemetry_(telemetry) {
|
||||
// Not implemented.
|
||||
}
|
||||
|
||||
ImageRequest::ImageRequest(ImageRequest &&other) noexcept
|
||||
: imageSource_(std::move(other.imageSource_)),
|
||||
telemetry_(std::move(other.telemetry_)),
|
||||
coordinator_(std::move(other.coordinator_)),
|
||||
instrumentation_(std::move(other.instrumentation_)) {
|
||||
coordinator_(std::move(other.coordinator_)) {
|
||||
// Not implemented.
|
||||
}
|
||||
|
||||
@@ -44,16 +40,5 @@ const std::shared_ptr<const ImageResponseObserverCoordinator>
|
||||
abort();
|
||||
}
|
||||
|
||||
const std::shared_ptr<const ImageInstrumentation>
|
||||
&ImageRequest::getSharedImageInstrumentation() const {
|
||||
// Not implemented
|
||||
abort();
|
||||
}
|
||||
|
||||
const ImageInstrumentation &ImageRequest::getImageInstrumentation() const {
|
||||
// Not implemented
|
||||
abort();
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
@@ -12,24 +12,19 @@ namespace react {
|
||||
|
||||
ImageRequest::ImageRequest(
|
||||
const ImageSource &imageSource,
|
||||
std::shared_ptr<const ImageTelemetry> telemetry,
|
||||
std::shared_ptr<const ImageInstrumentation> instrumentation)
|
||||
: imageSource_(imageSource),
|
||||
telemetry_(telemetry),
|
||||
instrumentation_(instrumentation) {
|
||||
std::shared_ptr<const ImageTelemetry> telemetry)
|
||||
: imageSource_(imageSource), telemetry_(telemetry) {
|
||||
coordinator_ = std::make_shared<ImageResponseObserverCoordinator>();
|
||||
}
|
||||
|
||||
ImageRequest::ImageRequest(ImageRequest &&other) noexcept
|
||||
: imageSource_(std::move(other.imageSource_)),
|
||||
telemetry_(std::move(other.telemetry_)),
|
||||
coordinator_(std::move(other.coordinator_)),
|
||||
instrumentation_(std::move(other.instrumentation_)) {
|
||||
coordinator_(std::move(other.coordinator_)) {
|
||||
other.moved_ = true;
|
||||
other.coordinator_ = nullptr;
|
||||
other.cancelRequest_ = nullptr;
|
||||
other.telemetry_ = nullptr;
|
||||
other.instrumentation_ = nullptr;
|
||||
}
|
||||
|
||||
ImageRequest::~ImageRequest() {
|
||||
@@ -58,14 +53,5 @@ const std::shared_ptr<const ImageResponseObserverCoordinator>
|
||||
return coordinator_;
|
||||
}
|
||||
|
||||
const std::shared_ptr<const ImageInstrumentation>
|
||||
&ImageRequest::getSharedImageInstrumentation() const {
|
||||
return instrumentation_;
|
||||
}
|
||||
|
||||
const ImageInstrumentation &ImageRequest::getImageInstrumentation() const {
|
||||
return *instrumentation_;
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <React/RCTImageLoaderWithAttributionProtocol.h>
|
||||
|
||||
#include <react/renderer/core/ReactPrimitives.h>
|
||||
#include <react/renderer/imagemanager/ImageInstrumentation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class RCTImageInstrumentationProxy final : public ImageInstrumentation {
|
||||
public:
|
||||
RCTImageInstrumentationProxy(id<RCTImageLoaderWithAttributionProtocol> imageLoader);
|
||||
~RCTImageInstrumentationProxy();
|
||||
|
||||
void didSetImage() const override;
|
||||
void didEnterVisibilityRange() const override;
|
||||
void didExitVisibilityRange() const override;
|
||||
|
||||
void trackNativeImageView(UIView *imageView) const;
|
||||
void setImageURLLoaderRequest(RCTImageURLLoaderRequest *request);
|
||||
|
||||
private:
|
||||
__weak id<RCTImageLoaderWithAttributionProtocol> imageLoader_;
|
||||
RCTImageURLLoaderRequest *imageURLLoaderRequest_;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#import "RCTImageInstrumentationProxy.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
RCTImageInstrumentationProxy::RCTImageInstrumentationProxy(id<RCTImageLoaderWithAttributionProtocol> imageLoader)
|
||||
: imageLoader_(imageLoader)
|
||||
{
|
||||
}
|
||||
|
||||
RCTImageInstrumentationProxy::~RCTImageInstrumentationProxy()
|
||||
{
|
||||
if (!imageURLLoaderRequest_) {
|
||||
return;
|
||||
}
|
||||
[imageLoader_ trackURLImageDidDestroy:imageURLLoaderRequest_];
|
||||
}
|
||||
|
||||
void RCTImageInstrumentationProxy::didSetImage() const
|
||||
{
|
||||
if (!RCTImageLoadingPerfInstrumentationEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!imageURLLoaderRequest_) {
|
||||
return;
|
||||
}
|
||||
|
||||
[imageLoader_ trackURLImageContentDidSetForRequest:imageURLLoaderRequest_];
|
||||
}
|
||||
|
||||
void RCTImageInstrumentationProxy::didEnterVisibilityRange() const
|
||||
{
|
||||
if (!RCTImageLoadingPerfInstrumentationEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO (T58941612): Not yet supported.
|
||||
if (!imageURLLoaderRequest_) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void RCTImageInstrumentationProxy::didExitVisibilityRange() const
|
||||
{
|
||||
if (!RCTImageLoadingPerfInstrumentationEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO (T58941612): Not yet supported.
|
||||
if (!imageURLLoaderRequest_) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void RCTImageInstrumentationProxy::trackNativeImageView(UIView *imageView) const
|
||||
{
|
||||
if (!RCTImageLoadingPerfInstrumentationEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!imageURLLoaderRequest_) {
|
||||
return;
|
||||
}
|
||||
[imageLoader_ trackURLImageVisibilityForRequest:imageURLLoaderRequest_ imageView:imageView];
|
||||
}
|
||||
|
||||
void RCTImageInstrumentationProxy::setImageURLLoaderRequest(RCTImageURLLoaderRequest *request)
|
||||
{
|
||||
imageURLLoaderRequest_ = request;
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -16,7 +16,6 @@
|
||||
#import <react/renderer/imagemanager/ImageResponse.h>
|
||||
#import <react/renderer/imagemanager/ImageResponseObserver.h>
|
||||
|
||||
#import "RCTImageInstrumentationProxy.h"
|
||||
#import "RCTImagePrimitivesConversions.h"
|
||||
|
||||
using namespace facebook::react;
|
||||
@@ -41,10 +40,9 @@ using namespace facebook::react;
|
||||
{
|
||||
SystraceSection s("RCTImageManager::requestImage");
|
||||
|
||||
auto imageInstrumentation = std::make_shared<RCTImageInstrumentationProxy>(_imageLoader);
|
||||
auto telemetry = std::make_shared<ImageTelemetry>(surfaceId);
|
||||
telemetry->willRequestUrl();
|
||||
auto imageRequest = ImageRequest(imageSource, telemetry, imageInstrumentation);
|
||||
auto imageRequest = ImageRequest(imageSource, telemetry);
|
||||
auto weakObserverCoordinator =
|
||||
(std::weak_ptr<const ImageResponseObserverCoordinator>)imageRequest.getSharedObserverCoordinator();
|
||||
|
||||
@@ -108,10 +106,6 @@ using namespace facebook::react;
|
||||
completionBlock:completionBlock];
|
||||
RCTImageLoaderCancellationBlock cancelationBlock = loaderRequest.cancellationBlock;
|
||||
sharedCancelationFunction.assign([cancelationBlock]() { cancelationBlock(); });
|
||||
|
||||
if (imageInstrumentation) {
|
||||
imageInstrumentation->setImageURLLoaderRequest(loaderRequest);
|
||||
}
|
||||
});
|
||||
|
||||
return imageRequest;
|
||||
|
||||
@@ -37,7 +37,7 @@ using namespace facebook::react;
|
||||
- (ImageRequest)requestImage:(ImageSource)imageSource surfaceId:(SurfaceId)surfaceId
|
||||
{
|
||||
auto telemetry = std::make_shared<ImageTelemetry>(surfaceId);
|
||||
auto imageRequest = ImageRequest(imageSource, telemetry, nullptr);
|
||||
auto imageRequest = ImageRequest(imageSource, telemetry);
|
||||
auto weakObserverCoordinator =
|
||||
(std::weak_ptr<const ImageResponseObserverCoordinator>)imageRequest.getSharedObserverCoordinator();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user