shorebirdtech / shorebird

Code Push for Flutter and other tools for Flutter businesses.
https://shorebird.dev
Other
1.97k stars 118 forks source link

fix: File reading slowdown after patch on iOS #1947

Open ismail-mufin opened 3 weeks ago

ismail-mufin commented 3 weeks ago

App ID: 5be7858a-e211-44f2-8120-5d21ce6bf5eb

Description

After sending a patch to iOS, there is extreme slowness when reading files on a screen where we have not made any changes.

Steps To Reproduce

  1. Send patch without changes in relevant screen
  2. Open gallery selector
  3. Select file

Expected Behavior

It should run at the same speed as before the patch.

Additional Context

πŸ“± App: ... (prod) (5be7858a-e211-44f2-8120-5d21ce6bf5eb)
🍧 Flavor: prod
πŸ“¦ Release Version: 1.6.5+96
πŸ•ΉοΈ  Platform: ios [aarch64 (2.48 MB)]
🟒 Track: Production
πŸ”— Running 42.9% on CPU

Package we used https://pub.dev/packages/crop_your_image, but the package was included in the release. Not in patch.

...

_imageSize = await _getImageResolution(_file.readAsBytesSync());

...

Future<Size> _getImageResolution(Uint8List imageData) async {
    ui.Codec codec = await ui.instantiateImageCodec(imageData);
    ui.FrameInfo frameInfo = await codec.getNextFrame();

    return Size(frameInfo.image.width.toDouble(), frameInfo.image.height.toDouble());
}

...

Crop(
              image: _file.readAsBytesSync(),

...

I shared a usage example above, everything works fine on Android.

felangel commented 3 weeks ago

Thanks for reporting this! I suspect this is related to #1892. We’re working hard to address low link percentages due to changes in the class table (if you add/remove classes our linker has a hard time determining what it can link). This should hopefully be resolved in a few weeks and we apologize for any inconvenience!

ismail-mufin commented 3 weeks ago

@felangel You're welcome, but I don't think it's related #1892 Because we know this, we pay attention. The link percentage is 42.9% and we did not add or remove any classes.

With a little deeper investigation, we confirmed that the long loading time was coming from within the crop_your_image package. So it's not our screens or providers.

This is strange because there is no change in the package, and the problem only occurs after the patch on iOS.

The package uses the image package. I suspect image decode functions are incompatible with your linker.

Could you do detailed check on this when you have time?

felangel commented 3 weeks ago

@felangel You're welcome, but I don't think it's related #1892 Because we know this, we pay attention. The link percentage is 42.9% and we did not add or remove any classes.

With a little deeper investigation, we confirmed that the long loading time was coming from within the crop_your_image package. So it's not our screens or providers.

This is strange because there is no change in the package, and the problem only occurs after the patch on iOS.

The package uses the image package. I suspect image decode functions are incompatible with your linker.

Could you do detailed check on this when you have time?

Can you provide some more context around what you modified in the patch?

ismail-mufin commented 3 weeks ago

@msalman-mufin Please explain the changes between the two commits. a710505f6768e39cc64ce5352060ea39e17a4e60 to 217347893ac7fcf2eea1b8cf43400c3c5910d324