Log when RCTImageView reloads and when assets are scaled
Summary: This sort of logging helped me identify issues with reloading images too frequently (and for trivial reasons), so leaving it in might be useful for future optimization work, or for anyone building apps using these components. @public Reviewed By: @alexeylang Differential Revision: D2475613
This commit is contained in:
parent
9293e54085
commit
3bbfab545a
|
@ -69,6 +69,21 @@ RCT_EXPORT_MODULE()
|
||||||
BOOL useMaximumSize = CGSizeEqualToSize(size, CGSizeZero);
|
BOOL useMaximumSize = CGSizeEqualToSize(size, CGSizeZero);
|
||||||
ALAssetRepresentation *representation = [asset defaultRepresentation];
|
ALAssetRepresentation *representation = [asset defaultRepresentation];
|
||||||
|
|
||||||
|
#if RCT_DEV
|
||||||
|
CGSize sizeBeingLoaded = size;
|
||||||
|
if (useMaximumSize) {
|
||||||
|
CGSize pointSize = representation.dimensions;
|
||||||
|
sizeBeingLoaded = CGSizeMake(pointSize.width * representation.scale, pointSize.height * representation.scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
CGSize screenSize = UIScreen.mainScreen.nativeBounds.size;
|
||||||
|
CGFloat maximumPixelDimension = fmax(screenSize.width, screenSize.height);
|
||||||
|
|
||||||
|
if (sizeBeingLoaded.width > maximumPixelDimension || sizeBeingLoaded.height > maximumPixelDimension) {
|
||||||
|
RCTLogInfo(@"[PERF ASSETS] Loading %@ at size %@, which is larger than screen size %@", representation.filename, NSStringFromCGSize(sizeBeingLoaded), NSStringFromCGSize(screenSize));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
UIImage *image;
|
UIImage *image;
|
||||||
NSError *error = nil;
|
NSError *error = nil;
|
||||||
if (useMaximumSize) {
|
if (useMaximumSize) {
|
||||||
|
|
|
@ -218,6 +218,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||||
|
|
||||||
if (RCTShouldReloadImageForSizeChange(imageSize, idealSize)) {
|
if (RCTShouldReloadImageForSizeChange(imageSize, idealSize)) {
|
||||||
if (RCTShouldReloadImageForSizeChange(_targetSize, idealSize)) {
|
if (RCTShouldReloadImageForSizeChange(_targetSize, idealSize)) {
|
||||||
|
RCTLogInfo(@"[PERF IMAGEVIEW] Reloading image %@ as size %@", _src, NSStringFromCGSize(idealSize));
|
||||||
|
|
||||||
// If the existing image or an image being loaded are not the right size, reload the asset in case there is a
|
// If the existing image or an image being loaded are not the right size, reload the asset in case there is a
|
||||||
// better size available.
|
// better size available.
|
||||||
_targetSize = idealSize;
|
_targetSize = idealSize;
|
||||||
|
|
Loading…
Reference in New Issue