NEW 257436
Image load fail in wkwebview when there is no cache;
https://bugs.webkit.org/show_bug.cgi?id=257436
Summary Image load fail in wkwebview when there is no cache;
hiugunmiao
Reported 2023-05-27 21:16:16 PDT
Created attachment 466517 [details] the demo render image fail in webview. I tring to render some image in the webview.but if i clear the cache before opening the webview.some image may be load fail(but render correctly after fresh). there is the swift code import UIKit import WebKit func clearCache() { // 取出cache文件夹目录 缓存文件都在这个目录下 let cachePath = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.cachesDirectory,FileManager.SearchPathDomainMask.userDomainMask, true).first // 取出文件夹下所有文件数组 let fileArr = FileManager.default.subpaths(atPath: cachePath!) // 遍历删除 for file in fileArr! { let path = (cachePath! as NSString).appending("/\(file)") if FileManager.default.fileExists(atPath: path) { do { try FileManager.default.removeItem(atPath: path) } catch { } } } } class ViewController: UIViewController, WKNavigationDelegate { var webView: WKWebView! override func loadView() { clearCache() webView = WKWebView() webView.navigationDelegate = self if #available(iOS 16.4, *) { webView.isInspectable = true } else { // Fallback on earlier versions } view = webView } override func viewDidLoad() { super.viewDidLoad() let url = URL(string: "my website html")! webView.load(URLRequest(url: url)) webView.allowsBackForwardNavigationGestures = true } } and the html file is in the attachment; I tring to find the key code that cause the bug; And i found that some thing can may cause the bug: 1. If i change the html root font size. 2. Chang the positon of the iamge 3. Change the number of images rendered 4.Different devices behave differently(same code normal in 14 pro max but fail in se3) It looks like a lot of factors are causing the problem。So i asked you for help.
Attachments
the demo render image fail in webview. (32.77 KB, text/html)
2023-05-27 21:16 PDT, hiugunmiao
no flags
the red area is image which load fail. (368.68 KB, image/png)
2023-05-27 21:23 PDT, hiugunmiao
no flags
hiugunmiao
Comment 1 2023-05-27 21:23:03 PDT
Created attachment 466518 [details] the red area is image which load fail.
Radar WebKit Bug Importer
Comment 2 2023-06-03 21:17:18 PDT
Note You need to log in before you can comment on or make changes to this bug.