flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.19k stars 26.64k forks source link

WebViewWidget stops loading the url if its inside IndexedStack in IOS #145575

Closed YDA93 closed 1 month ago

YDA93 commented 1 month ago

Steps to reproduce

Using ios device do the following:

  1. Initialize a WebViewController controller
  2. Create a IndexedStack with index that is not pointing to WebViewWidget
  3. Try to load the url in IOS device you will notice the progress stops immediately at value 11/100 or less

Expected results

Should load the url normally even when IndexedStack is not pointing to WebViewWidget

Actual results

8 out of 10 times it won't load the url

Code sample

Code sample ```dart IndexedStack( index: 0, sizing: StackFit.expand, children: [ const Center( child: CircularProgressIndicator( valueColor: AlwaysStoppedAnimation(Colors.white), ), ), WebViewWidget(controller: _controller), Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( locale.sorry, style: const TextStyle( fontSize: 40, fontWeight: FontWeight.bold, color: Colors.white, ), ), const SizedBox(height: 5), Text( locale.couldNotReachThePage, style: const TextStyle( fontSize: ConstantFonts.large, fontWeight: FontWeight.bold, color: Colors.white, ), ), const SizedBox(height: 25), PrimaryButton( text: locale.tryAgain, width: 200, onTap: _controller.reload, ), ], ), ), ], ) ```

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.19.4, on macOS 14.4 23E214 darwin-arm64, locale en-KW) • Flutter version 3.19.4 on channel stable at /Users/yousefalmutairi/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 68bfaea224 (25 hours ago), 2024-03-20 15:36:31 -0700 • Engine revision a5c24f538d • Dart version 3.3.2 • DevTools version 2.31.1 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at /Users/yousefalmutairi/Library/Android/sdk • Platform android-34, build-tools 30.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15E204a • CocoaPods version 1.15.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • android-studio-dir = /Applications/Android Studio.app • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694) [✓] VS Code (version 1.87.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.84.0 [✓] Connected device (4 available) • SM S711B (mobile) • 192.168.0.117:5555 • android-arm64 • Android 14 (API 34) • iPhone (mobile) • 00008130-000158AE3498001C • ios • iOS 17.4 21E219 • macOS (desktop) • macos • darwin-arm64 • macOS 14.4 23E214 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 123.0.6312.59 ! Error: Browsing on the local area network for iPhone 11 Pro Max. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27) [✓] Network resources • All expected network resources are available. • No issues found! ```
danagbemava-nc commented 1 month ago

Hi @YDA93, what version of webview_flutter & webview_flutter_wkwebview are you experiencing this issue with?

Does this work as expected on android?

YDA93 commented 1 month ago

@danagbemava-nc

Works perfectly in android. Never fails to load the url.

While in ios most of the time it fails because the widget is not visible on the screen or the widget state is not preserved maybe.

I noticed the issue also persist when using PageView.

Currently my workaround is to wrap WebViewWidget with Stack and show loading indicator above it instead of using IndexedStack or PageView.

workaround ``` Stack( children: [ WebViewWidget(controller: _controller), IgnorePointer( ignoring: !_isLoading, child: Opacity( opacity: _isLoading ? 1 : 0, child: const Material( color: Colors.black54, child: Center( child: LoadingIndicator( color: Colors.white, loadingIndicatorType: LoadingIndicatorType.fourRotatingDots, ), ), ), ), ), ], ) ```
pubspec.lock ``` webview_flutter: dependency: "direct main" description: name: webview_flutter sha256: "25e1b6e839e8cbfbd708abc6f85ed09d1727e24e08e08c6b8590d7c65c9a8932" url: "https://pub.dev" source: hosted version: "4.7.0" webview_flutter_android: dependency: transitive description: name: webview_flutter_android sha256: f038ee2fae73b509dde1bc9d2c5a50ca92054282de17631a9a3d515883740934 url: "https://pub.dev" source: hosted version: "3.16.0" webview_flutter_platform_interface: dependency: transitive description: name: webview_flutter_platform_interface sha256: d937581d6e558908d7ae3dc1989c4f87b786891ab47bb9df7de548a151779d8d url: "https://pub.dev" source: hosted version: "2.10.0" webview_flutter_wkwebview: dependency: transitive description: name: webview_flutter_wkwebview sha256: f12f8d8a99784b863e8b85e4a9a5e3cf1839d6803d2c0c3e0533a8f3c5a992a7 url: "https://pub.dev" source: hosted version: "3.13.0" ```
danagbemava-nc commented 1 month ago

Hi @YDA93, thanks for the update.

What were you trying to achieve by putting the Webview inside the IndexedStack? Please also share a complete minimal reproducible code sample.

Thank you

github-actions[bot] commented 1 month ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. If you find this problem please file a new issue with the same description, what happens, logs and the output of 'flutter doctor -v'. All system setups can be slightly different so it's always better to open new issues and reference the related ones. Thanks for your contribution.

github-actions[bot] commented 2 weeks ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.