mirror of
https://github.com/Tencent/Hippy.git
synced 2026-10-26 11:10:06 +08:00
fix(ios): avoid zero size crash when using UIGraphics api in debug mode
This commit is contained in:
@@ -642,6 +642,11 @@ void HippyBoarderColorsRelease(HippyBorderColors c) {
|
||||
return YES;
|
||||
}
|
||||
else if (self.backgroundImageUrl) {
|
||||
CGSize size = theFrame.size;
|
||||
if (0 >= size.width || 0 >= size.height) {
|
||||
contentBlock(nil);
|
||||
return YES;
|
||||
}
|
||||
CGFloat backgroundPositionX = self.backgroundPositionX;
|
||||
CGFloat backgroundPositionY = self.backgroundPositionY;
|
||||
HippyBackgroundImageCacheManager *weakBackgroundCacheManager = [self backgroundCachemanager];
|
||||
|
||||
@@ -110,6 +110,7 @@ NSString *const HippyPageImageFormatJPEG = @"jpeg";
|
||||
if (!rootView) {
|
||||
HippyLogWarn(@"PageModel, screen cast, root view is nil");
|
||||
completion(@{});
|
||||
return;
|
||||
}
|
||||
CGFloat viewWidth = rootView.frame.size.width;
|
||||
CGFloat viewHeight = rootView.frame.size.height;
|
||||
@@ -118,6 +119,10 @@ NSString *const HippyPageImageFormatJPEG = @"jpeg";
|
||||
CGFloat scaleX = self.maxSize.width / viewWidth;
|
||||
CGFloat scaleY = self.maxSize.height / viewHeight;
|
||||
scale = MIN(scaleX, scaleY);
|
||||
} else {
|
||||
HippyLogWarn(@"PageModel, screen cast, root view size is 0");
|
||||
completion(@{});
|
||||
return;
|
||||
}
|
||||
// root view snapshot
|
||||
UIGraphicsBeginImageContextWithOptions(rootView.frame.size, NO, scale);
|
||||
@@ -141,8 +146,7 @@ NSString *const HippyPageImageFormatJPEG = @"jpeg";
|
||||
resultJSON[HippyPageKeySessionId] = @(timestamp);
|
||||
self.lastTimestamp = timestamp;
|
||||
completion(resultJSON);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
completion(@{});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user