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

[PINNED] Large iOS app after upgrading to Flutter 1.12.13 #47101

Closed
rx123rx opened this issue Dec 16, 2019 · 19 comments
Closed

[PINNED] Large iOS app after upgrading to Flutter 1.12.13 #47101

rx123rx opened this issue Dec 16, 2019 · 19 comments
Labels
a: size Reducing IPA/APK/JS sizes c: performance Relates to speed or footprint issues (see "perf:" labels) customer: crowd Affects or could affect many people, though not necessarily a specific customer. perf: app size Performance issues related to app size (binary/code size) or disk space platform-ios iOS applications specifically t: xcode "xcodebuild" on iOS and general Xcode project management

Comments

@rx123rx
Copy link

rx123rx commented Dec 16, 2019

After I upgrade flutter to 1.12.13, I built a very big ios app with my flutter project. The ios app is 160+mb now.But before I upgrade flutter sdk, it is normal size 20+mb. The ios project has added a podfile,and I have updated the podfile to the newest podfile template.

The podfile content look like below:

platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug-Runner_dev' => :debug,
  'Debug-Runner_production' => :debug,
  'Release-Runner_dev' => :release,
  'Release-Runner_production' => :release,
}

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  generated_key_values = {}
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) do |line|
    next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
    plugin = line.split(pattern=separator)
    if plugin.length == 2
      podname = plugin[0].strip()
      path = plugin[1].strip()
      podpath = File.expand_path("#{path}", file_abs_path)
      generated_key_values[podname] = podpath
    else
      puts "Invalid plugin specification: #{line}"
    end
  end
  generated_key_values
end

target 'Runner' do
  pod 'AFNetworking', '>= 3.2.1'
  pod 'AMapLocation', '>= 2.6.3'
  pod 'CocoaHTTPServer', '>= 2.3'
  pod 'JMLink', '>= 1.0.0'
  pod 'NSDate-Extensions', '>= 0.0.1'
  pod 'QQ_MTA/CrashReporter', '>= 2.5.4'
  pod 'RNTimer', '>= 0.0.1'
  pod 'SDWebImage', '>= 4.4.6'
  pod 'SQPersist', '>= 1.0.5'
  pod 'UMCCommon', '>= 2.0.0'
  pod 'UMCShare/Social/ReducedWeChat', '>= 6.9.5'
  pod 'WechatOpenSDK', '1.8.2'
  pod 'YYCategories', '>= 1.0.4'
  pod 'MJExtension', '>= 3.2.1'

  # Flutter Pod

  copied_flutter_dir = File.join(__dir__, 'Flutter')
  copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
  copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
  unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
    # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
    # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
    # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.

    generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
    unless File.exist?(generated_xcode_build_settings_path)
      raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
    end
    generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
    cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];

    unless File.exist?(copied_framework_path)
      FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
    end
    unless File.exist?(copied_podspec_path)
      FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
    end
  end

  # Keep pod path relative so it can be checked into Podfile.lock.
  pod 'Flutter', :path => 'Flutter'

  # Plugin Pods

  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.each do |name, path|
    symlink = File.join('.symlinks', 'plugins', name)
    File.symlink(path, symlink)
    pod name, :path => File.join(symlink, 'ios')
  end
end

# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

The flutter sdk detail is :

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale zh-Hans-CN)
    • Flutter version 1.12.13+hotfix.5 at /Users/renxiao/development/flutter
    • Framework revision 27321ebbad (5 days ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/renxiao/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

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

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

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

[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

Please help me to fix this problem.

@sallymariehollywood
Copy link

This issue is because the the Flutter framework binaries are now in excess of 172MB even when we build a release app. This prevents even the smallest app being approved at the app store because of their size restrictions.

@therealjohnsummer
Copy link

Severe regression issue in 1.12.13. I have rolled back to 1.91 and the issue does not occur, until 1.12.13 is resolved I suggest (If you can do without what 1.12.13 offers) not upgrading to this release if you have imminent app store releases.

@iapicca iapicca added a: size Reducing IPA/APK/JS sizes customer: crowd Affects or could affect many people, though not necessarily a specific customer. perf: app size Performance issues related to app size (binary/code size) or disk space t: xcode "xcodebuild" on iOS and general Xcode project management platform-ios iOS applications specifically c: regression It was better in the past than it is now labels Dec 16, 2019
@shufit
Copy link

shufit commented Dec 17, 2019

i also build a very big iOS app with my project

@rx123rx
Copy link
Author

rx123rx commented Dec 17, 2019

i also build a very big iOS app with my project

I have downgraded to 1.9.1.

@Erenyang
Copy link

I have the same problem and hope to solve it quickly.

@songfei
Copy link

songfei commented Dec 19, 2019

same issue, Flutter.framework/Flutter file from 7M to 171M

1576745839896

But there seems to be no problem, after Apple has finished processing.
The picture below is the result in Apple Connect app.

截屏2019-12-19下午5 19 24

@rx123rx
Copy link
Author

rx123rx commented Dec 19, 2019

same issue, Flutter.framework/Flutter file from 7M to 171M

1576745839896

But there seems to be no problem, after Apple has finished processing.
The picture below is the result in Apple Connect app.

截屏2019-12-19下午5 19 24

if there is a podfile in your ios project, this issue will appear, or will not appear.

@songfei
Copy link

songfei commented Dec 19, 2019

same issue, Flutter.framework/Flutter file from 7M to 171M
1576745839896
But there seems to be no problem, after Apple has finished processing.
The picture below is the result in Apple Connect app.
截屏2019-12-19下午5 19 24

if there is a podfile in your ios project, this issue will appear, or will not appear.

I don't understand what you're talking about.
So how is the iOS project built, if there is no Podfile file?

BTW:You can use Chinese, and others can use translation software if they want to know.

@xster
Copy link
Member

xster commented Dec 19, 2019

@dnfield anything else we need to cover here in this issue?

@rx123rx
Copy link
Author

rx123rx commented Dec 19, 2019

same issue, Flutter.framework/Flutter file from 7M to 171M
1576745839896
But there seems to be no problem, after Apple has finished processing.
The picture below is the result in Apple Connect app.
截屏2019-12-19下午5 19 24

if there is a podfile in your ios project, this issue will appear, or will not appear.

I don't understand what you're talking about.
So how is the iOS project built, if there is no Podfile file?

BTW:You can use Chinese, and others can use translation software if they want to know.

我发现如果创建一个新的flutter工程,里面的iOS工程是没有podfile的,然后执行flutter build ios,构建出来的APP大小就是正常大小。如果我为iOS工程里添加一个podfile,并且执行pod install之后,然后再去构建iOS APP,这时APP的大小就会变得巨大。所以我猜测是不是podfile影响到了新版flutter SDK的tree shaking之类的操作。

@bpaul7101
Copy link

A Flutter Engine contact has advised me to go back to either 1.78 or 1.91 as this issue is not likely to be addressed or fixed any time soon. They mentioned that 1.12.x was an ambition release and lots of issues/regression bugs have arisen which will be addressed in the second quarter of 2020.

@rx123rx
Copy link
Author

rx123rx commented Dec 19, 2019

A Flutter Engine contact has advised me to go back to either 1.78 or 1.91 as this issue is not likely to be addressed or fixed any time soon. They mentioned that 1.12.x was an ambition release and lots of issues/regression bugs have arisen which will be addressed in the second quarter of 2020.

All right.

@talent-apps
Copy link

Can someone from the Flutter team please address this issue?
If the latest stable release 1.12.X is not really stable, it should be properly communicated to developers who rely on these releases in production.

@sallymariehollywood
Copy link

Maybe off topic for this raised issue (so apologise in advance) , but I now have this issue #41679 - but this appears to be pre-1.12 , I wont know unless I rollback to 1.91 or 1.78 (Which I plan to do). This is quite severe , does anybody else have this ?

Also mentioned here :

#43004

And this one really shows the issue :

#43804

Although the fix to the scaffold doesnt help me.

@dnfield
Copy link
Contributor

dnfield commented Dec 19, 2019

This is not a bug, and is not as scary as it first may seem.

The release Flutter.framework now contains bitcode, which makes for a very large intermediate artifact. This bitcode is either recompiled or stripped out automatically by the process of creating a distribution IPA. You can see this from Xcode by creating an ad hoc or development archive. Whether you check that or not, it will be done for you by Xcode and the App store (as seen by @songfei in #47101 (comment)).

This is not a flutter specific issue, rather it's just the way LLVM bitcode works. You can read more details in our docs:

https://flutter.dev/docs/resources/faq#how-big-is-the-flutter-engine
https://flutter.dev/docs/perf/app-size#ios

You can also read about how this same issue affects other libraries like Realm:

realm/realm-swift#4450 (comment)

We all work hard to try to make stable releases stable. This one has had it's share of regressions, but happily the main issue reported here is not one of them. And FWIW, we have a performance benchmark for every commit that tracks the release size of iOS and Android apps. We take that very seriously.

I'm going to close this issue. I'm also going to temporarily pin it since I suspect many will miss other forms of documentation linked in here.

@dnfield dnfield closed this as completed Dec 19, 2019
@dnfield dnfield pinned this issue Dec 19, 2019
@dnfield dnfield removed the c: regression It was better in the past than it is now label Dec 19, 2019
@dnfield
Copy link
Contributor

dnfield commented Dec 19, 2019

I'll leave this open for further comments as long as it doesn't get too spammy or off topic :)

@krisgiesing krisgiesing unpinned this issue Dec 19, 2019
@dnfield dnfield pinned this issue Dec 19, 2019
@jmagman jmagman unpinned this issue Dec 19, 2019
@rx123rx
Copy link
Author

rx123rx commented Dec 19, 2019

This is not a bug, and is not as scary as it first may seem.

The release Flutter.framework now contains bitcode, which makes for a very large intermediate artifact. This bitcode is either recompiled or stripped out automatically by the process of creating a distribution IPA. You can see this from Xcode by creating an ad hoc or development archive. Whether you check that or not, it will be done for you by Xcode and the App store (as seen by @songfei in #47101 (comment)).

This is not a flutter specific issue, rather it's just the way LLVM bitcode works. You can read more details in our docs:

https://flutter.dev/docs/resources/faq#how-big-is-the-flutter-engine
https://flutter.dev/docs/perf/app-size#ios

You can also read about how this same issue affects other libraries like Realm:

realm/realm-cocoa#4450 (comment)

We all work hard to try to make stable releases stable. This one has had it's share of regressions, but happily the main issue reported here is not one of them. And FWIW, we have a performance benchmark for every commit that tracks the release size of iOS and Android apps. We take that very seriously.

I'm going to close this issue. I'm also going to temporarily pin it since I suspect many will miss other forms of documentation linked in here.

Oh, it all turned out to be a misunderstanding.Thank you.

@dnfield dnfield pinned this issue Dec 20, 2019
@jmagman jmagman unpinned this issue Dec 20, 2019
@dnfield dnfield pinned this issue Dec 20, 2019
@HansMuller HansMuller unpinned this issue Dec 20, 2019
@mklim mklim pinned this issue Dec 20, 2019
@mklim mklim changed the title After I upgrade flutter to 1.12.13, I built a very big ios app with my flutter project. [PINNED] After I upgrade flutter to 1.12.13, I built a very big ios app with my flutter project. Dec 20, 2019
@HansMuller HansMuller unpinned this issue Dec 20, 2019
@Hixie Hixie pinned this issue Dec 20, 2019
@Hixie Hixie changed the title [PINNED] After I upgrade flutter to 1.12.13, I built a very big ios app with my flutter project. [PINNED] Large iOS app after upgrading to Flutter 1.12.13 Dec 20, 2019
@godofredoc godofredoc unpinned this issue Dec 20, 2019
@dnfield dnfield pinned this issue Dec 20, 2019
@chinmaygarde chinmaygarde unpinned this issue Dec 21, 2019
@DanTup DanTup pinned this issue Dec 21, 2019
@fyeeme
Copy link

fyeeme commented Dec 22, 2019

my App is 402.7 MB!!!
image

[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.15.2 19C57, locale en-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Chrome - develop for the web
[✓] Android Studio
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3)
[✓] VS Code (version 1.41.1)
[✓] Connected device (4 available)

• No issues found!

@dnfield
Copy link
Contributor

dnfield commented Dec 23, 2019

@fyeeme see #47101 (comment)

@flutter flutter locked as resolved and limited conversation to collaborators Dec 23, 2019
@VladyslavBondarenko VladyslavBondarenko unpinned this issue Dec 31, 2019
@liyuqian liyuqian added the c: performance Relates to speed or footprint issues (see "perf:" labels) label Mar 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: size Reducing IPA/APK/JS sizes c: performance Relates to speed or footprint issues (see "perf:" labels) customer: crowd Affects or could affect many people, though not necessarily a specific customer. perf: app size Performance issues related to app size (binary/code size) or disk space platform-ios iOS applications specifically t: xcode "xcodebuild" on iOS and general Xcode project management
Projects
None yet
Development

No branches or pull requests