[Webkit-unassigned] [Bug 257436] New: Image load fail in wkwebview when there is no cache;

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat May 27 21:16:16 PDT 2023


https://bugs.webkit.org/show_bug.cgi?id=257436

            Bug ID: 257436
           Summary: Image load fail in wkwebview when there is no cache;
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: All
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Images
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: codingpoorcat at gmail.com
                CC: sabouhallawa at apple.com

Created attachment 466517

  --> https://bugs.webkit.org/attachment.cgi?id=466517&action=review

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20230528/089eefc3/attachment.htm>


More information about the webkit-unassigned mailing list