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

IOS App Black Screen Issue After Applying Patch with Low Dart Code Sharing Percentage #2251

Closed
xang555 opened this issue Jun 17, 2024 · 2 comments
Assignees
Labels
bug Something isn't working do-no-harm Using Shorebird should never be worse than not.

Comments

@xang555
Copy link

xang555 commented Jun 17, 2024

App ID: a5c8b996-8a16-402e-89c0-29cad445f495

Description

When updating the code, the patch works well on Android but results in a black screen on iOS upon re-running the app.

Steps To Reproduce

  1. Apply the code changes as below:
   class RandomDigitCanvas extends StatelessWidget {
     final int length;
     final Color fontColor;
     final double fontSize;
     
     const RandomDigitCanvas({
       super.key,
       required this.length,
       this.fontColor = Colors.black,
       this.fontSize = 50.0,
     });
     
     @override
     Widget build(BuildContext context) {
       return CustomPaint(
         size: const Size(150, 400), // Adjust the size as needed
         painter: RandomDigitPainter(
           length: length,
           fontColor: fontColor,
           fontSize: fontSize,
         ),
       );
     }
   }

   class RandomDigitPainter extends CustomPainter {
     final int length;
     final Color fontColor;
     final double fontSize;
     final Random _random = Random();
     
     RandomDigitPainter({
       required this.length,
       required this.fontColor,
       required this.fontSize,
     });
     
     @override
     void paint(Canvas canvas, Size size) {
       final textStyle = GoogleFonts.comforter(
         fontSize: fontSize,
         color: fontColor,
       );
     
       for (int i = 0; i < length; i++) {
         String digit = _random.nextInt(10).toString();
         final textPainter = TextPainter(
           text: TextSpan(text: digit, style: textStyle),
           textDirection: TextDirection.ltr,
         );
     
         textPainter.layout(
           minWidth: 0,
           maxWidth: size.width,
         );
     
         double offsetX = (size.width - textPainter.width) / 2;
         double offsetY = (size.height / length) * i * 0.65 +
             (size.height / length - textPainter.height) / 2;
     
         canvas.save();
         double angle = _random.nextDouble() * pi / 2 - pi / 4; // Random angle between -45 to 45 degrees
         double randomXOffset = _random.nextDouble() * 20 - 10; // Increased horizontal offset
         double randomYOffset = _random.nextDouble() * 20 - 10; // Increased vertical offset
     
         canvas.translate(
             offsetX + textPainter.width / 2, offsetY + textPainter.height / 2);
         canvas.rotate(angle);
         canvas.translate(-(offsetX + textPainter.width / 2) + randomXOffset,
             -(offsetY + textPainter.height / 2) + randomYOffset);
     
         textPainter.paint(canvas, Offset(offsetX, offsetY));
         canvas.restore();
       }
     }
     
     @override
     bool shouldRepaint(covariant CustomPainter oldDelegate) {
       return false;
     }
   }

and

   child: Container(
  margin: const EdgeInsets.only(bottom: 40),
  color: Colors.black,
  child: Center(
    child: Container(
      margin: const EdgeInsets.only(top: 50),
      child: RandomDigitCanvas(
        length: 6,
        fontSize: 124,
        fontColor: Theme.of(context).colorScheme.primary,
      ),
    ),
  ),
),
  1. Run the app on iOS.
  2. Observe the black screen.
  3. Check the warning message upon running the patch.

Additional Context

Warning message received when running the patch:

[WARN] shorebird patch was only able to share 14.2% of Dart code with the released app.
This means the patched code may execute slower than expected.
https://docs.shorebird.dev/status#link-percentage-ios

Shorebird version:

Shorebird 1.1.11 • git@github.com:shorebirdtech/shorebird.git
Flutter 3.22.2 • revision c20374bd2ceb8bdff113cce13a4bb6180021d958
Engine • revision 14449967f2149612759c8c2fd7527dc3114d3934
@xang555 xang555 added the bug Something isn't working label Jun 17, 2024
@xang555 xang555 changed the title fix: IOS App Black Screen Issue After Applying Patch with Low Dart Code Sharing Percentage Jun 17, 2024
@eseidel
Copy link
Contributor

eseidel commented Jun 17, 2024

Thank you for the report! This is definitely not expected (both the 14% linking and the black screen).

The linking will be fixed by #1892
The black screen may be #2237

We hope to have a fix for both as soon as this week, sorry for the inconvenience.

@eseidel eseidel added the do-no-harm Using Shorebird should never be worse than not. label Jun 17, 2024
@felangel
Copy link
Contributor

This should be fixed now in v1.1.12.
Please let us know if this is still an issue after upgrading and re-releasing and patching using Shorebird v1.1.12, thanks!

@felangel felangel self-assigned this Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working do-no-harm Using Shorebird should never be worse than not.
Projects
None yet
Development

No branches or pull requests

3 participants