Skip to content

[web] Safari white frame when removing (last?) platform view #84832

Closed
flutter-team-archive/engine
#27154

Description

@peerwaya

I recently built an app on flutter web using the latest master and I am experiencing random white screens or crashes when tapping around, see the link here App

RPReplay_Final1623992205.MP4

Flutter Doctor

[✓] Flutter (Channel master, 2.3.0-17.0.pre.390, on Mac OS X 10.15.7 19H105 darwin-x64, locale
    en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.2)
[✓] VS Code (version 1.57.0)
[✓] Connected device (2 available)

Activity

  1. darshankawar commented on Jun 18, 2021

    @darshankawar
    Member

    @peerwaya
    Can you provide the crash log it generates ? Is the behavior replicable locally in debug mode or in release mode ?
    Can you also provide a complete minimal reproducible code sample that we can use that shows the crashes ?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 18, 2021
  3. peerwaya commented on Jun 18, 2021

    @peerwaya
    Author

    This is currently running in release mode, no crash log. happens randomly.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 18, 2021
  5. peerwaya commented on Jun 18, 2021

    @peerwaya
    Author

    You can try the latest gallery app in release mode on the latest master running on ios safari

  6. darshankawar commented on Jun 18, 2021

    @darshankawar
    Member

    I tried the gallery app and ran it in release mode using latest master and opened it in safari browser. Clicked through the app features but don't seem to get any crash / white frames.

    Screenshot 2021-06-18 at 4 58 34 PM

  7. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 18, 2021
  8. peerwaya commented on Jun 18, 2021

    @peerwaya
    Author

    Hi @darshankawar , please run it on iOS safari not desktop safari, I am working on a minimum sample

  9. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 18, 2021
  10. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 18, 2021
  11. peerwaya commented on Jun 23, 2021

    @peerwaya
    Author

    Here is a minimum sample
    repo: https://github.com/GotokHQ/mini_test
    demo: https://dev-web-gotok.firebaseapp.com/#/

    import 'package:animations/animations.dart';
    import 'package:flutter/material.dart';
    import 'package:url_launcher/link.dart';
    
    void main() {
      runApp(const MyApp());
    }
    
    const url = 'https://google.com';
    
    class MyApp extends StatelessWidget {
      const MyApp({Key? key}) : super(key: key);
    
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter Demo',
          theme: ThemeData(
            // This is the theme of your application.
            //
            // Try running your application with "flutter run". You'll see the
            // application has a blue toolbar. Then, without quitting the app, try
            // changing the primarySwatch below to Colors.green and then invoke
            // "hot reload" (press "r" in the console where you ran "flutter run",
            // or simply save your changes to "hot reload" in a Flutter IDE).
            // Notice that the counter didn't reset back to zero; the application
            // is not restarted.
            primarySwatch: Colors.blue,
          ),
          home: const MyHomePage(title: 'Flutter Demo Home Page'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      const MyHomePage({Key? key, required this.title}) : super(key: key);
      final String title;
    
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      int _selectedIndex = 0;
      final PageStorageBucket bucket = PageStorageBucket();
    
      final List<Widget> pages = const [
        Page1(),
        Page2(),
      ];
    
      Widget _bottomNavigationBar(int selectedIndex) => SafeArea(
            child: BottomNavigationBar(
              onTap: (int index) => setState(() => _selectedIndex = index),
              currentIndex: selectedIndex,
              items: const [
                BottomNavigationBarItem(
                    icon: Icon(Icons.local_dining), label: 'Page1'),
                BottomNavigationBarItem(
                    icon: Icon(Icons.assignment), label: 'Page2'),
              ],
            ),
            bottom: true,
          );
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          backgroundColor: Colors.amber,
          body: PageTransitionSwitcher(
            transitionBuilder: (
              Widget child,
              Animation<double> animation,
              Animation<double> secondaryAnimation,
            ) {
              return FadeThroughTransition(
                animation: animation,
                secondaryAnimation: secondaryAnimation,
                child: child,
                fillColor: Colors.amber,
              );
            },
            child: KeyedSubtree(
              key: ValueKey(_selectedIndex),
              child: pages[_selectedIndex],
            ),
          ),
          bottomNavigationBar: _bottomNavigationBar(
              _selectedIndex), // This trailing comma makes auto-formatting nicer for build methods.
        );
      }
    }
    
    class Page1 extends StatelessWidget {
      const Page1({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: const Text('Page 1'),
          ),
          backgroundColor: Colors.amber,
          body: const SizedBox.expand(
            child: Center(
              child: Text('Empty Page'),
            ),
          ),
        );
      }
    }
    
    class Page2 extends StatelessWidget {
      const Page2({Key? key}) : super(key: key);
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: const Text('Page 2'),
          ),
          backgroundColor: Colors.amber,
          body: Center(
            child: Link(
              uri: Uri.parse(url),
              target: LinkTarget.blank,
              builder: (context, onPressed) {
                return ElevatedButton(
                    onPressed: onPressed, child: const Text('Button 2'));
              },
            ),
          ),
        );
      }
    }
    
  12. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jun 23, 2021
  13. peerwaya commented on Jun 23, 2021

    @peerwaya
    Author

    I noticed this happens with a Link Widget or something with a Platform view underneath on web especially iOS Safari. It's not so noticeable on chrome. It is fine on stable channel but It seems to have started after the slots refactor done by @ditman. @ditman what do you think?

    https://dev-web-gotok.firebaseapp.com/#/

    Onyemaechis-MacBook-Pro:mini_test evenmatrix$    flutter doctor
    Doctor summary (to see all details, run flutter doctor -v):
    [✓] Flutter (Channel master, 2.3.0-17.0.pre.421, on Mac OS X 10.15.7 19H105 darwin-x64, locale en-US)
    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        ✗ Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
    [✓] Xcode - develop for iOS and macOS
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 4.2)
    [✓] VS Code (version 1.57.1)
    [✓] Connected device (3 available)
    
    RPReplay_Final1624431039.MP4
  14. peerwaya commented on Jun 23, 2021

    @peerwaya
    Author

    To see the effect, try switching the tabs

  15. 15 remaining items

  16. peerwaya commented on Jun 30, 2021

    @peerwaya
    Author

    is it possible to fallback to the implementation without slots for safari as a temporary workaround?

  17. ditman commented on Jun 30, 2021

    @ditman
    Member

    @peerwaya use flutter channel master for that, until we land the workaround.

  18. ditman commented on Jun 30, 2021

    @ditman
    Member

    I've reproduced the white page in development mode, locally, and with canvaskit rendering.

    This is good news, because it probably means that this is a ShadowDOM Safari bug. I'm diving deeper.

  19. ditman commented on Jul 1, 2021

    @ditman
    Member

    OK, I think I've minimally reproduced the issue (without flutter web). Here's the link:

    https://jsfiddle.net/ditman/rmwqjLah

    If you visit that fiddle in Safari, the end result will be a "red" screen, but if you use Chrome, the end result will be "green".

    I hope the JS code is easy to understand; I'll create a bug for Safari ASAP, but first I'll try to implement a mitigation strategy into flutter. We have two options:

    1. Delete the "slotted" content before the slot itself. This could be a permanent fix, but I need to dive deeper in the ordering of the flutter events regarding web views.
    2. Never delete the root container of the "slotted" content (this will seem like a "DOM node leak" from the outside, but this would be a temporary fix until Safari gets fixed).
  20. ditman commented on Jul 3, 2021

    @ditman
    Member

    We have a workaround for this that doesn't leave DOM nodes hanging. Deleting the slotted content before the slot was not practical, due to how flutter rendering pipeline works.

  21. ditman commented on Jul 3, 2021

    @ditman
    Member

    The PR with a workaround is here:

    The underlying issue has been reported to Webkit, here:

  22. changed the title [-][web] iOS Safari random crashes/white frame[/-] [+][web] Safari white frame when removing (last?) platform view[/+] on Jul 7, 2021
  23. ditman commented on Jul 7, 2021

    @ditman
    Member

    The fix is rolling into flutter/master here:

  24. ditman commented on Jul 7, 2021

    @ditman
    Member

    The fix has rolled into flutter master successfully.

  25. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jul 8, 2021
  26. github-actions commented on Jul 30, 2021

    @github-actions

    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.

  27. locked as resolved and limited conversation to collaborators on Jul 30, 2021
  28. added
    P0Critical issues such as a build break or regression
    and removed on Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: platform-viewsEmbedding Android/iOS views in Flutter appsbrowser: safari-macosonly manifests in Safari on macOSengineflutter/engine related. See also e: labels.platform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions