Skip to content

[iOS] onReceivedError is not triggered on iframe errors. #2753

@darkstarx

Description

@darkstarx

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I use InAppWebView with InAppWebViewInitialData on iOS and don't receive any errors when the internet is turned off. When using URLRequest with src from the iframe, errors appear.

Expected Behavior

Errors appear even from iframes on iOS. On Android platform they already do.

Steps with code example to reproduce

Steps with code example to reproduce
    final initialSettings = InAppWebViewSettings(
      isInspectable: kDebugMode,
      mediaPlaybackRequiresUserGesture: false,
      allowsInlineMediaPlayback: true,
      allowBackgroundAudioPlaying: false,
      iframeAllow: allow,
      iframeAllowFullscreen: true,
      transparentBackground: true,
      useHybridComposition: defaultTargetPlatform != TargetPlatform.android,
    );
    final initialData = InAppWebViewInitialData(
      data: '<iframe src="https://vkvideo.ru/video_ext.php?oid=-211142264&id=456239264&hash=0debc89d0241310a" width="100%" height="100%" scrolling="no" frameBorder="0"allow="autoplay; encrypted-media; fullscreen; picture-in-picture; screen-wake-lock;"></iframe>',
      baseUrl: WebUri('https://vkvideo.ru/video_ext.php?oid=-211142264&id=456239264&hash=0debc89d0241310a'),
    );
    return InAppWebView(
      initialData: initialData,
      initialSettings: initialSettings,
      shouldOverrideUrlLoading: _shouldOverrideUrlLoading,
      onReceivedError: _onError,
    );

Then turn off wifi on the device and show the widget. _onError is not triggered even with isForMainFrame = false

Stacktrace/Logs

Stacktrace/Logs
[IOSInAppWebViewWidget] (iOS) IOSInAppWebViewWidget ID 67 calling "onWebViewCreated" using []
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "onUpdateVisitedHistory" using {url: https://vkvideo.ru/video_ext.php?oid=-211142264&id=456239264&hash=0debc89d0241310a, isReload: null}
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "shouldOverrideUrlLoading" using {isForMainFrame: true, targetFrame: {isMainFrame: true, request: {networkServiceType: 0, allowsCellularAccess: true, method: GET, attribution: 0, mainDocumentURL: null, timeoutInterval: 60.0, cachePolicy: 0, assumesHTTP3Capable: false, allowsConstrainedNetworkAccess: true, httpShouldUsePipelining: false, headers: null, url: , allowsExpensiveNetworkAccess: true, httpShouldHandleCookies: true, body: null}, securityOrigin: {protocol: , host: , port: 0}}, isRedirect: null, shouldPerformDownload: false, navigationType: -1, sourceFrame: {isMainFrame: true, request: {url: , allowsCellularAccess: true, mainDocumentURL: null, method: GET, body: null, httpShouldHandleCookies: true, assumesHTTP3Capable: false, networkServiceType: 0, attribution: 0, httpShouldUsePipelining: false, allowsConstrainedNetworkAccess: true, allowsExpensiveNetworkAccess: true, timeoutInterval: 60.0, cachePolicy: 0, headers: null}, securityOrigin: {port: 0, prot...
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "onLoadStart" using {url: https://vkvideo.ru/video_ext.php?oid=-211142264&id=456239264&hash=0debc89d0241310a}
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "onPageCommitVisible" using {url: https://vkvideo.ru/video_ext.php?oid=-211142264&id=456239264&hash=0debc89d0241310a}
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "onContentSizeChanged" using {newContentSize: {width: 980.0, height: 616.0}, oldContentSize: {height: 0.0, width: 0.0}}
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "onZoomScaleChanged" using {oldScale: 1.0, newScale: 0.3897959291934967}
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "shouldOverrideUrlLoading" using {isForMainFrame: false, targetFrame: {isMainFrame: false, request: {body: null, headers: {}, method: GET, url: , allowsCellularAccess: true, attribution: 0, allowsExpensiveNetworkAccess: true, assumesHTTP3Capable: false, httpShouldUsePipelining: true, networkServiceType: 0, mainDocumentURL: null, httpShouldHandleCookies: true, allowsConstrainedNetworkAccess: true, timeoutInterval: 2147483647.0, cachePolicy: 0}, securityOrigin: {host: vkvideo.ru, port: 0, protocol: https}}, isRedirect: null, shouldPerformDownload: false, navigationType: -1, sourceFrame: {securityOrigin: {port: 0, host: vkvideo.ru, protocol: https}, request: {url: https://vkvideo.ru/video_ext.php?oid=-211142264&id=456239264&hash=0debc89d0241310a, assumesHTTP3Capable: false, httpShouldHandleCookies: true, method: GET, cachePolicy: 0, allowsConstrainedNetworkAccess: true, body: null, timeoutInterval: 2147483647.0, mainDocumentURL: null, headers: {}, attribution: ...
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "onContentSizeChanged" using {newContentSize: {height: 246.0, width: 382.0}, oldContentSize: {width: 980.0, height: 616.0}}
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "onContentSizeChanged" using {newContentSize: {width: 382.0, height: 246.0}, oldContentSize: {width: 980.0, height: 632.0}}
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "onProgressChanged" using {progress: 100}
[IOSInAppWebViewController] (iOS) WebView ID 67 calling "onLoadStop" using {url: https://vkvideo.ru/video_ext.php?oid=-211142264&id=456239264&hash=0debc89d0241310a}

Flutter version

Flutter (Channel stable, 3.38.5, on macOS 26.1 25B78 darwin-arm64)

Operating System, Device-specific and/or Tool

iOS 18.7.2

Plugin version

flutter_inappwebview: ^6.1.5

Additional information

No response

Self grab

  • I'm ready to work on this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions