Unable to capture WebGL images using native screenshot methods in WKWebView rendering.

I used some code to capture WebGL images from a webpage. It works fine on iOS 16 and above, but the images generated in iOS 16 and below are black. Can someone help me solve this problem?

UIGraphicsBeginImageContextWithOptions(CGSizeMake(self.recordView.frame.size.width, self.recordView.frame.size.height), NO,  scale);
CGContextRef ctx = UIGraphicsGetCurrentContext();
if (!ctx) {
    NSLog(@"error");
}
[self.recordView drawViewHierarchyInRect:CGRectMake(0, 0, self.recordView.frame.size.width, self.recordView.frame.size.height) afterScreenUpdates:YES];
UIImage *vImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();