Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App doesn't delete cached LaunchImage and creates un ugly flickering btw the old cached and the new LaunchImage #55952

Closed
tomasbaran opened this issue Apr 29, 2020 · 8 comments
Labels
a: assets Packaging, accessing, or using assets framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-ios iOS applications specifically t: xcode "xcodebuild" on iOS and general Xcode project management

Comments

@tomasbaran
Copy link

Demo

You can see flickering between the old (still cached original LaunchImage) of purple color and the new LaunchImage (the only one that should have been shown as a LaunchImage) of pink color

flickering-bug

Steps to Reproduce

  1. Run a default app (Tap on the button to see the counter)
  2. Change LaunchImage (ideally to something easy to notice such as all red screen)
  3. Run the app now

Expected results:
It should only show me the red LaunchImage

Actual results:
Ugly flickering/flash from the 1. original white LaunchImage -> 2. the new red LaunchImage screen

** More Details **

I know that it's not Flutter's issue but iOS's issue because iOS doesn't delete the old cached LaunchImage. But I believe that Flutter doesn't have to inherit iOS's bugs, we can do better that than and can even avoid iOS native bugs.

I even found some solutions but since I'm not a Swift developer, I cannot implement them even though they seem very simple to implement.

https://rambo.codes/posts/2019-12-09-clearing-your-apps-launch-screen-cache-on-ios

https://stackoverflow.com/questions/33002829/ios-keeping-old-launch-screen-and-app-icon-after-update

I would appreciate anyone familiar with Swift maybe in the meantime to share how to fix it in Swift or where exactly (on what line number and in which file) to call the clearLaunchScreenCache() function.

Logs
[✓] Flutter (Channel master, 1.18.0-9.0.pre.45, on Mac OS X 10.15.4 19E287, locale es-ES)
    • Flutter version 1.18.0-9.0.pre.45 at /Users/tomas/Developer/flutter
    • Framework revision 43ce3fd988 (18 hours ago), 2020-04-28 10:49:02 -0700
    • Engine revision 4bcfae82c7
    • Dart version 2.9.0 (build 2.9.0-3.0.dev a69cb6d700)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/tomas/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.4.1, Build version 11E503a
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.44.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.9.1

[✓] Connected device (3 available)
    • iPhone 11  • 8945646B-58CE-451E-82E8-487FB361872E • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-4 (simulator)
    • Web Server • web-server                           • web-javascript • Flutter Tools
    • Chrome     • chrome                               • web-javascript • Google Chrome 81.0.4044.122

• No issues found!

@tomasbaran tomasbaran changed the title Doesn't delete cached LaunchImage and creates un ugly flickering btw the old cached and the new LaunchImage App doesn't delete cached LaunchImage and creates un ugly flickering btw the old cached and the new LaunchImage Apr 29, 2020
@iapicca
Copy link
Contributor

iapicca commented Apr 29, 2020

Hi @tomasbaran
can you please provide a reproducible minimal code sample.
Thank you

@iapicca iapicca added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Apr 29, 2020
@tomasbaran
Copy link
Author

tomasbaran commented Apr 29, 2020

Sure, as I say above—just use the default app that comes with Flutter. But it doesn't matter it can be any code... But I can copy it for you. Here is the lib/main.dart

1. Code Sample
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // 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,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug painting" (press "p" in the console, choose the
          // "Toggle Debug Paint" action from the Flutter Inspector in Android
          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
          // to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

2. Then use these LaunchImages (purple)

LaunchImage
LaunchImage@2x
LaunchImage@3x

3. Then change for these LaunchImages (pink)

LaunchImage2
LaunchImage2@2x
LaunchImage2@3x

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 29, 2020
@iapicca
Copy link
Contributor

iapicca commented Apr 30, 2020

Hi @tomasbaran
I apologise, I misunderstood the initial issue
the launch screen is handle native side as described in the docs
without this being any kind of endorsement it seems possible to clear the cache

import UIKit

public extension UIApplication {
    func clearLaunchScreenCache() {
        do {
            try FileManager.default.removeItem(atPath: NSHomeDirectory()+"/Library/SplashBoard")
        } catch {
            print("Failed to delete launch screen cache: \(error)")
        }
    }
}

Please see https://flutter.dev/community for resources and asking questions like this,
you may also get some help if you post it on Stack Overflow.
Closing, as this isn't an issue with Flutter itself,
if you disagree please write in the comments and I will reopen it
Thank you

@iapicca iapicca closed this as completed Apr 30, 2020
@tomasbaran
Copy link
Author

tomasbaran commented Apr 30, 2020

Thank you for giving me an answer @iapicca, however, you didn't tell me anything I wouldn't already know. Everything you answered I explained in my issue, including the link and the code you provided. If you read my issue thoroughly I even explained that it's not originally the Flutter issue, however, this issue concerns the Flutter apps too.

This iOS bug makes it even a bigger bug for Flutter since Xcode doesn't come up with any default LaunchImage but Flutter does (the white one), so therefore after the first launch of Flutter it caches a LaunchedImage which you can't clear.

With that being said, I think Flutter can prevent inheriting this iOS issue. That's why I reported it. Maybe just by including the lines created by Rambo (https://rambo.codes/posts/2019-12-09-clearing-your-apps-launch-screen-cache-on-ios) in the iOS folder in the Flutter default folder. Or at least by commenting them in the AppDelegate (I guess since I'm not a Swift developer).

@iapicca iapicca reopened this Apr 30, 2020
@iapicca iapicca added a: assets Packaging, accessing, or using assets framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-ios iOS applications specifically t: xcode "xcodebuild" on iOS and general Xcode project management and removed in triage Presently being triaged by the triage team labels Apr 30, 2020
@VladyslavBondarenko
Copy link

I can't reproduce it with current master 1.21.0-6.0.pre.117 running on iOS 13.6 simulator.
The image is changed even without flutter clean or deleting app from device.

flutter doctor -v
[✓] Flutter (Channel master, 1.21.0-6.0.pre.117, on Mac OS X 10.15.6 19G73, locale en-GB)
    • Flutter version 1.21.0-6.0.pre.117 at /Users/nevercode/dev/flutter
    • Framework revision 7ec2d360bc (2 hours ago), 2020-07-29 23:25:38 -0700
    • Engine revision a9910e409c
    • Dart version 2.10.0 (build 2.10.0-1.0.dev 24c7666def)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/nevercode/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 47.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.47.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.12.2

[✓] Connected device (6 available)
    • Redmi Note 7 (mobile)       • 6345c469                                 • android-arm64  • Android 9 (API 28)
    • Nevercode’s iPhone (mobile) • b668e524315069f3db3661ac11ff1f66afafebdb • ios            • iOS 13.6
    • iPhone 11 Pro Max (mobile)  • 55C8466B-5367-492B-8EFE-EC45D980571F     • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)
    • macOS (desktop)             • macos                                    • darwin-x64     • Mac OS X 10.15.6 19G73
    • Web Server (web)            • web-server                               • web-javascript • Flutter Tools
    • Chrome (web)                • chrome                                   • web-javascript • Google Chrome 84.0.4147.105

• No issues found!

@tomasbaran can you confirm is it fixed?

@VladyslavBondarenko VladyslavBondarenko added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 30, 2020
@tomasbaran
Copy link
Author

tomasbaran commented Jul 30, 2020

Wow! What is that some kind of a magic? :) No one tried to fix this issue and it got fixed by itself? :D

It seems to be fixed, man @VladyslavBondarenko :) I couldn't believe it! :) but you are right I couldn't reproduce this issue any more either. heh

flutter doctor -v
[✓] Flutter (Channel master, 1.21.0-6.0.pre.117, on Mac OS X 10.15.5 19F101, locale es-ES)
    • Flutter version 1.21.0-6.0.pre.117 at /Users/tomas/Development/flutter
    • Framework revision 7ec2d360bc (7 hours ago), 2020-07-29 23:25:38 -0700
    • Engine revision a9910e409c
    • Dart version 2.10.0 (build 2.10.0-1.0.dev 24c7666def)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/tomas/Library/Android/sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.47.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.12.2

[✓] Connected device (3 available)
    • iPhone 11 (mobile) • 04298E38-2633-4586-B868-1FBD5C708AF7 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)
    • Web Server (web)   • web-server                           • web-javascript • Flutter Tools
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 84.0.4147.105

• No issues found!

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 30, 2020
@VladyslavBondarenko
Copy link

There could be a duplicate issue, which was fixed in some version in between, I'm not aware. And I didn't try other channels. Closing then if it's working as intended with the latest version

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: assets Packaging, accessing, or using assets framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-ios iOS applications specifically t: xcode "xcodebuild" on iOS and general Xcode project management
Projects
None yet
Development

No branches or pull requests

3 participants