Issue 1:
This might be related/relevant to background execution of Dart code tracked at #3671

While trying to enhance a plugin for a Google-internal notification platform, we ran into a problem. On Android, the implementation requires initializing state during Application.onCreate. This initialization asks for a lot of information including assets, version, project id and flavor of the app.

For native Android apps, these are injected into the application context so they are available immediately. For Flutter apps, these are typically available only in Dart code which means they are inaccessible without a FlutterView. For now, we had to duplicate this information on Android side which is less than ideal.

Ideally, we would like to be able to ask the Dart application during Application.onCreate to supply this information. Going one step further, it would be nice if plugin framework allowed registration during application initialization instead of activity.

Issue 2:
Hi,

Currently, we use methods below to catch exceptions in dart

runZoned<Future<Null>>(() async {
FlutterError.onError = ExceptionHandler.dumpErrorToConsole;
ExceptionHandler.setupWithAppEntry();
runApp(new MyApp());
}, onError: (error, stackTrace) async {
print('Zone caught an error');
await ExceptionHandler.singleton.reportError(error, stackTrace);
});

It can help us collect dart exceptions and errors so that we may fix it in time, a report we got from the server side is as below:

#0 IOClient.send (package:http/src/io_client.dart:30)

#1 BaseClient._sendUnstreamed (package:http/src/base_client.dart:171)

#2 BaseClient.get (package:http/src/base_client.dart:34)
#3 NetworkImage._loadAsync (package:flutter/src/painting/image_provider.dart:441)

#4 NetworkImage.load (package:flutter/src/painting/image_provider.dart:426)
#5 ImageProvider.resolve.. (package:flutter/src/painting/image_provider.dart:266)
#6 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:82)
#7 ImageProvider.resolve. (package:flutter/src/painting/image_provider.dart:266)
#8 SynchronousFuture.then (package:flutter/src/foundation/synchronous_future.dart:38)
#9 ImageProvider.resolve (package:flutter/src/painting/image_provider.dart:264)
#10 _FXImageState._resolveImage (package:fwn_idlefish/ui_utils/fx_image.dart:253)
#11 _FXImageState.didChangeDependencies (package:fwn_idlefish/ui_utils/fx_image.dart:210)
#12 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3750)
#13 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600)
#14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#15 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#16 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4633)
#17 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#18 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#19 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4633)
#20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#21 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#22 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636)
#23 Element.rebuild (package:flutter/src/widgets/framework.dart:3478)
#24 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605)
#25 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600)
#26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#27 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4738)
#28 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#29 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#30 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636)
#31 Element.rebuild (package:flutter/src/widgets/framework.dart:3478)
#32 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605)
#33 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600)
#34 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:3938)
#35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#36 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4738)
#37 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#38 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#39 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4633)
#40 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#41 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#42 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4633)
#43 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#44 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#45 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636)
#46 Element.rebuild (package:flutter/src/widgets/framework.dart:3478)
#47 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605)
#48 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600)
#49 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#50 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4738)
#51 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#52 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#53 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636)
#54 Element.rebuild (package:flutter/src/widgets/framework.dart:3478)
#55 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605)
#56 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3752)
#57 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600)
#58 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#59 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#60 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4633)
#61 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#62 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#63 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636)
#64 Element.rebuild (package:flutter/src/widgets/framework.dart:3478)
#65 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605)
#66 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600)
#67 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#68 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#69 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636)
#70 Element.rebuild (package:flutter/src/widgets/framework.dart:3478)
#71 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605)
#72 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600)
#73 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:3938)
#74 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#75 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#76 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3636)
#77 Element.rebuild (package:flutter/src/widgets/framework.dart:3478)
#78 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3605)
#79 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3752)
#80 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3600)
#81 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2890)
#82 Element.updateChild (package:flutter/src/widgets/framework.dart:2693)
#83 SliverMultiBoxAdaptorElement.createChild. (package:flutter/src/widgets/sliver.dart:729)
#84 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2205)
#85 SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:722)
#86 RenderSliverMultiBoxAdaptor._createOrObtainChild. (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:254)
#87 RenderObject.invokeLayoutCallback. (package:flutter/src/rendering/object.dart:1666)
#88 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:740)
#89 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1666)
#90 RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:243)
#91 RenderSliverMultiBoxAdaptor.insertAndLayoutChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:411)
#92 RenderSliverList.performLayout.advance (package:flutter/src/rendering/sliver_list.dart:190)
#93 RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:233)
#94 RenderObject.layout (package:flutter/src/rendering/object.dart:1570)
#95 RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:182)
#96 RenderObject.layout (package:flutter/src/rendering/object.dart:1570)
#97 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:285)
#98 RenderViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1008)
#99 RenderViewport.performLayout (package:flutter/src/rendering/viewport.dart:932)
#100 RenderObject.layout (package:flutter/src/rendering/object.dart:1570)
#101 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107)
#102 RenderObject.layout (package:flutter/src/rendering/object.dart:1570)
#103 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107)
#104 RenderObject.layout (package:flutter/src/rendering/object.dart:1570)
#105 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107)
#106 RenderObject.layout (package:flutter/src/rendering/object.dart:1570)
#107 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107)
#108 RenderObject.layout (package:flutter/src/rendering/object.dart:1570)
#109 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107)
#110 RenderObject.layout (package:flutter/src/rendering/object.dart:1570)
#111 RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:107)
#112 RenderObject.layout (package:flutter/src/rendering/object.dart:1570)
#113 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:509)
#114 RenderObject.layout (package:flutter/src/rendering/object.dart:1570)
#115 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:124)
#116 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:328)
#117 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:194)
#118 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:338)
#119 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1445)
#120 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:709)
#121 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:270)
#122 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:622)
#123 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:208)
#124 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990)
#125 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930)
#126 BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842)
#127 _rootRun (dart:async/zone.dart:1126)
#128 _CustomZone.run (dart:async/zone.dart:1023)
#129 _CustomZone.runGuarded (dart:async/zone.dart:925)
#130 _invoke (file:///Users/kangkai/fwn_idlefish/flutter/bin/cache/pkg/sky_engine/lib/ui/hooks.dart:122)
#131 _drawFrame (file:///Users/kangkai/fwn_idlefish/flutter/bin/cache/pkg/sky_engine/lib/ui/hooks.dart:109)

As shown above, I noticed that those source code information is contained in the final product even in a release build. So I have two questions:

1.Can we decrease the apk/ipa size notably by removing those source code information?

2.If those information is trimmed from the final product, can we restore the source code information from a source<-->symbols table stored locally when we catch an exception?

[✓] Flutter (Channel xy_beta_v0.5.6, v0.5.7-pre.32, on Mac OS X 10.14 18A365a, locale en-CN)
• Flutter version 0.5.7-pre.32 at /Users/kylewong/Codes/fwn_idlefish/flutter
• Framework revision 65cf48c56b (5 days ago), 2018-08-11 13:59:50 +0800
• Engine revision 6fe748490d
• Dart version 2.0.0-dev.63.0.flutter-4c9689c1d2

[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/kylewong/Library/Android/sdk
• Android NDK at /Users/kylewong/Library/Android/sdk/ndk-bundle
• Platform android-27, build-tools 27.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_152-release-1024-b01)
• All Android licenses accepted.

[!] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.4.1, Build version 9F2000
• ios-deploy 1.9.2
! CocoaPods out of date (1.5.0 is recommended).
CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
For more info, see https://flutter.io/platform-plugins
To upgrade:
brew upgrade cocoapods
pod setup

[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 26.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)

[!] VS Code (version 1.25.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected devices (1 available)

@eseidelGoogle