mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
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:
committed by
facebook-github-bot-9
parent
9293e54085
commit
3bbfab545a
@@ -69,6 +69,21 @@ RCT_EXPORT_MODULE()
|
||||
BOOL useMaximumSize = CGSizeEqualToSize(size, CGSizeZero);
|
||||
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;
|
||||
NSError *error = nil;
|
||||
if (useMaximumSize) {
|
||||
|
||||
Reference in New Issue
Block a user