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
Android Release Build NoSuchMethodError #22131
Comments
Do you have any detailed stack trace (e.g. try looking into |
@mraleph Added |
We would need more information to diagnose this. Can you edit /// Returns an element of the swatch table.
Color operator [](T index) {
print(">>> Invoked ColorSwatch[$index]: ${index.runtimeType} / ${index.hashCode}");
return _swatch[index];
} then |
@maguinis Here's the updated logcat
It didn't seem that there was anything wrong. After debugging a bit more I found the issue. I had my primarySwatch declared without a const keyword, like this static MaterialColor primarySwatch = MaterialColor(
0xFFAE4244,
<int, Color>{
50: Color(0xFFECE6E6),
100: Color(0xFFD0C1C1),
200: Color(0xFFB19798),
300: Color(0xFF916D6E),
400: Color(0xFF7A4E4F),
500: Color(0xFFAE4244),
600: Color(0xFF5A2A2B),
700: Color(0xFF502324),
800: Color(0xFF461D1E),
900: Color(0xFF341213)
},
); After adding const in the declaration it started working just fine. Strange that it occurred only on release builds. |
Whatever we are seeing this is totally not an expected effect from omitting the Thanks to your pointer I was able to reproduce this error now and I am looking into this. |
Reduction: class X {
final Map<int, String> data;
const X(this.data);
}
const f = X({ 1: "ok-f" });
final g = X({ 1: "ok-g" });
void main() {
print(f.data[1]);
print(g.data[1]);
} ╭─vegorov@volhv ~/src/dart/sdk ‹master›
╰─$ pkg/vm/tool/precompiler2 /tmp/z.dart /tmp/z.aot && out/ReleaseX64/dart_precompiled_runtime /tmp/z.aot
Unhandled exception:
NoSuchMethodError: The method '&' was called on null.
Receiver: null
Tried calling: &()
#0 _HashBase._hashPattern (dart:collection/runtime/libcompact_hash.dart:98)
#1 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin._getValueOrData (dart:collection/runtime/libcompact_hash.dart:329)
#2 __InternalLinkedHashMap&_HashVMBase&MapMixin&_LinkedHashMapMixin.[] (dart:collection/runtime/libcompact_hash.dart:351)
#3 main (file:///tmp/z.dart:2)
#4 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:289)
#5 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171) The bug is in the interaction between TFA and backend field type inference, that does not take constants into account. TFA provides inferred type for assigning to @alexmarkov |
Constant objects are evaluated and boiled down to a list of field-value pairs, so there are no more constructor invocations involved. For the remaining constructor invocations TFA yields correct results here. So the problem is in the incorrect type inference of final field types in backend, which doesn't account for already evaluated constant objects. Maybe instead of fixing that limited type inference in the backend we should replace it with results from TFA. |
…ompiler.cc Type inference for final fields in precompiler.cc is limited and does not properly handle constant objects. This change hooks up field types inferred by TFA and removes the inference in precompiler.cc. Fixes: flutter/flutter#22131 Change-Id: Ida65cd211074623928bb2a7d48dc58d5e53511b8 Reviewed-on: https://dart-review.googlesource.com/76562 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
The fix landed in Dart SDK (dart-lang/sdk@f81709c). Incorrect analysis is removed and replaced with results of TFA. Keeping the issue open until the fix is rolled into Flutter. |
The fix was rolled to Flutter in aef9804. |
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 |
Occurs only on release build, right at the app's startup time
Flutter Doctor
adb logcat
P.S. Works fine on v0.9.1
The text was updated successfully, but these errors were encountered: