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

Beta: Text and Icons not always showing correctly in dialog #64936

Closed
DustyLamp opened this issue Aug 31, 2020 · 18 comments
Closed

Beta: Text and Icons not always showing correctly in dialog #64936

DustyLamp opened this issue Aug 31, 2020 · 18 comments
Labels
a: typography Text rendering, possibly libtxt dependency: skia Skia team may need to help us e: device-specific Only manifests on certain devices f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. P1 High-priority issues at the top of the work list platform-android Android applications specifically

Comments

@DustyLamp
Copy link

DustyLamp commented Aug 31, 2020

Text and icons do not show correctly about 50% of the time in all of my dialogs, but only on Flutter Beta Channel.

Issues are intermittent and include:

  • Some of the text showing and some not
  • Icons not showing
  • All of the text not showing

There's nothing else that's problematic - all sizes and styling look fine.

It's a relatively new issue - I haven't seen it before and I generally stick to the Beta Channel. I haven't been able to reproduce it on Stable.

There's nothing indicating an issue and there's no difference in the console between Beta and Stable.

Beta:
image

Stable:
image


UPDATE
Here's the output from flutter doctor -v:
image

I'm only seeing the issue on Android currently - I haven't tested it yet on IOS, but will post the results as soon as I have the ability to.

I'm seeing the issue on Samsung Galaxy S10e. I've had someone tell me that there is a similar problem (screen is blank) that extends beyond Dialogs on Pixel 4 XL. Reverting back to standard also fixed their issue.

I'm using ScreenUtil to set the size of the Text Widget's TextStyle like so:

Text(
  "Here, have a dialog",
  style: TextStyle(
      color: Colors.black,
      fontWeight: FontWeight.bold,
      fontSize: ScreenUtil().setSp(20.0)),
),

Perhaps it's a race condition between the Dialog opening time and calculating the text size?

This reproduces it on the Samsung Galaxy S10e:

import 'dart:math';

import 'package:flutter/material.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Sometimes Sad Dialog',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

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

class _MyHomePageState extends State<MyHomePage> {
  double textSize;
  @override
  void initState() {
    // sp20 = 8.465608465608465;
    textSize = 8;
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Container(
          child: RaisedButton(
            color: Colors.purple,
            onPressed: () {
              showBouncyDialog();
            },
            child: Text(
              "Give me a dialog",
              style: TextStyle(
                color: Colors.white,
                fontSize: textSize,
              ),
            ),
          ),
        ),
      ),
    );
  }

  void showBouncyDialog() async {
    await showGeneralDialog<bool>(
      pageBuilder: (context, anim1, anim2) {},
      barrierLabel: '',
      barrierColor: Colors.black.withOpacity(0.3),
      transitionDuration: Duration(milliseconds: 400),
      context: context,
      barrierDismissible: true,
      transitionBuilder: (
        BuildContext context,
        Animation<double> animation,
        Animation<double> anotherAnimation,
        Widget child,
      ) {
        final double curvedValue =
            max(0, Curves.elasticInOut.transform(animation.value));

        return Transform.scale(
          scale: curvedValue,
          child: Dialog(
            child: Padding(
              padding: EdgeInsets.all(50.0),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(
                    "Here, have a dialog",
                    style: TextStyle(
                      color: Colors.black,
                      fontWeight: FontWeight.bold,
                      fontSize: textSize,
                    ),
                  ),
                  SizedBox(
                    height: 20,
                  ),
                  Text(
                    "Here, have some more test that is of a longer length to see if wrapping is working.",
                    style: TextStyle(
                      color: Colors.blue,
                      fontSize: textSize,
                    ),
                  ),
                  SizedBox(
                    height: 20,
                  ),
                  Center(
                    child: RaisedButton(
                      onPressed: () {
                        Navigator.of(context).pop();
                      },
                      color: Colors.red,
                      child: Text(
                        "Pop my cherry",
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: textSize,
                        ),
                      ),
                    ),
                  )
                ],
              ),
            ),
          ),
        );
      },
    );
  }
}

And here are screenshots of it acting up with the code above:

expected
Screenshot_20200831-211102

nothing showing
Screenshot_20200831-211433

Topmost Text not showing
Screenshot_20200831-211442

@darshankawar
Copy link
Member

Hi @DustyLamp,
Please provide flutter doctor -v and a minimal complete reproducible code sample that shows the issue.
Also specify platform (Android, iOS) and devices on which you see this issue.
Thanks.

@darshankawar darshankawar 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 Aug 31, 2020
@DustyLamp
Copy link
Author

Thanks @darshankawar - I've made an update to the original comment

@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 Aug 31, 2020
@darshankawar
Copy link
Member

Hi @DustyLamp, thanks for the code sample.
I see that you are using flutter_screen_util plugin which is 3rd party. Just to segregate the issue, is it possible for you to check by removing this plugin related code and try again with core code and see if the issue still occurs ?

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 1, 2020
@DustyLamp
Copy link
Author

DustyLamp commented Sep 1, 2020

Yes - good question @darshankawar.

I can reproduce the issue with text sizes 11 or smaller, but I believe I have seen instances of it occurring with different sized texts (see original screenshots)

I've edited the code to remove flutter_screen_util plugin.

@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 Sep 1, 2020
@darshankawar
Copy link
Member

darshankawar commented Sep 1, 2020

Thanks @DustyLamp for the code sample.
I tried it on latest beta and on Samsung S10+ device, but didn't see the issue.

64936.mp4.zip

flutter doctor -v
Flutter 1.21.0-9.2.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 81a45ec2e5 (5 days ago) • 2020-08-27 14:14:33 -0700
Engine • revision 20a9531835
Tools • Dart 2.10.0 (build 2.10.0-7.3.beta)

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.21.0-9.2.pre, on Mac OS X 10.15.2 19C57, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 29.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 (Xcode 11.6)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[✓] Connected device (4 available)

! Doctor found issues in 1 category.

Since you said, it's intermittent, I'd suggest you keep an eye on it and see if there's any pattern that causes the issue.
Thanks.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Sep 1, 2020
@DustyLamp
Copy link
Author

When I say it's intermittent, it's happening every second time that I push the button in my code so it's not rare. It happens more often than not.

As for patterns that cause it:

  • Usually, when I first open the application it works without a problem
  • The second time I start seeing the issue and then the issue usually persists from that point onwards.

See gif below:
Screen_Recording_20200901-163824_2

@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 Sep 1, 2020
@darshankawar
Copy link
Member

I am unable to replicate this issue on latest beta and on the devices I tried, but per OP, it's happening at their end. Will need further analysis on it,so keeping this issue open.

@darshankawar darshankawar added a: typography Text rendering, possibly libtxt found in release: 1.21 Found to occur in 1.21 passed first triage platform-android Android applications specifically e: device-specific Only manifests on certain devices f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. and removed in triage Presently being triaged by the triage team labels Sep 2, 2020
@igoriuz
Copy link

igoriuz commented Sep 8, 2020

I'm experiencing something similar. Text/Icon widgets are rarely shown after animations. Happens both on android and ios platforms. As far as i can tell, it affects debug and release builds.

missing_text2

Here's some example code:

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(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: Center(
        child: MicroAnimationBounceIn(
          child: RaisedButton(
            onPressed: () {},
            child: Text("This Text disappears in release builds"),
          ),
        ),
      ),
    );
  }
}

class MicroAnimationBounceIn extends StatefulWidget {
  final Widget child;
  final Duration delayBounce;
  final Duration duration;

  MicroAnimationBounceIn({
    Key key,
    this.child,
    this.delayBounce = const Duration(milliseconds: 100),
    this.duration = const Duration(seconds: 1),
  }) : super(key: key);

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

class _MicroAnimationBounceInState extends State<MicroAnimationBounceIn>
    with SingleTickerProviderStateMixin {
  AnimationController _animationController;
  Animation<double> _animation;

  @override
  void initState() {
    super.initState();

    _animationController = AnimationController(
      duration: widget.duration,
      vsync: this,
      animationBehavior: AnimationBehavior.preserve,
    );

    _animation = Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation(
        parent: _animationController, curve: Curves.elasticInOut))
      ..addListener(() {
        setState(() {});
      });

    Future.delayed(widget.delayBounce)
        .then((value) => _animationController.forward());
  }

  @override
  void dispose() {
    _animationController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Transform.scale(
      scale: _animation.value,
      child: widget.child,
    );
  }
}

@igoriuz
Copy link

igoriuz commented Sep 8, 2020

Another important note: This problem appears on physical devices more often than on simulators/emulators.

My flutter doctor output:

Flutter 1.21.0-9.2.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 81a45ec2e5 (11 days ago) • 2020-08-27 14:14:33 -0700
Engine • revision 20a9531835
Tools • Dart 2.10.0 (build 2.10.0-7.3.beta)

@igoriuz
Copy link

igoriuz commented Sep 9, 2020

Could you reproduce it with my example code @darshankawar ?

@darshankawar darshankawar removed the found in release: 1.21 Found to occur in 1.21 label Sep 9, 2020
@jason-simmons
Copy link
Member

I reproduced this issue using the sample code from #64936 (comment)

It happens reliably on a Moto G4 if I run the app in release mode, hit the back button, and resume the app. The animation will run but the text will not be rendered.

Bisected this to google/skia@a5b9860. The text shows if I remove the !fInitialMatrix.rectStaysRect() check from GrTextBlob::canReuse.

@herbderby @bungeman

@jason-simmons jason-simmons added the dependency: skia Skia team may need to help us label Sep 18, 2020
@herbderby
Copy link

Can you print the values of fInitialMatrix when the problem happens?

@chinmaygarde chinmaygarde added the P1 High-priority issues at the top of the work list label Sep 21, 2020
@jason-simmons
Copy link
Member

The last fInitialMatrix seen during the animation is:

m0=0.000065 m1=0.000000 m2=540.004028
m3=0.000000 m4=0.000065 m5=888.019592
m6=0.000000 m7=0.000000 m8=1.000000

@herbderby
Copy link

herbderby commented Sep 22, 2020 via email

@jason-simmons
Copy link
Member

The SkFont in this example always has font size 14.

The 0.000065 value in the matrix happens because the text is wrapped in an animation that applies a scale transform. When the animation works properly, the fInitialMatrix starts at 0.000065 and gradually increases as the animation progresses, eventually reaching a value of 3.0.

If I remove the !fInitialMatrix.rectStaysRect() check then I see that behavior consistently.

With the rectStaysRect check I sometimes see the fInitialMatrix scale factor stuck at 0.000065 even though the animation should have increased the scale.

I don't have a standalone C++ reproduction.

@chinmaygarde
Copy link
Member

pull bot pushed a commit to Mu-L/skia that referenced this issue Sep 24, 2020
If the blob is empty, then try to regenerate it. Using
this method caused a slowdown in Skia perf, so we
added an extra check to allow some empty blobs through
for perf performance. The perf problem was caused by
SKPs generate empty blobs because of font mismatches.
Flutter has shown that scaling from very small to
normal size is not correctly handled by the existing
check. This CL favors correctness over optimizing empty
text blob and always regenerates empty blobs.

flutter/flutter#64936

Change-Id: Ib18ecb684b0af5cf6dce274b6dc09a9c61b17c77
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319031
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
@jason-simmons
Copy link
Member

The change was reverted in Skia and rolled into the engine.

@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 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: typography Text rendering, possibly libtxt dependency: skia Skia team may need to help us e: device-specific Only manifests on certain devices f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. P1 High-priority issues at the top of the work list platform-android Android applications specifically
Projects
None yet
Development

No branches or pull requests

6 participants