-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Dart2js release build may make generic parameters dynamic #41449
Comments
This was tested on the up-to-date master channel of Flutter (1.18.0-5.0.pre-57), which uses Dart 2.8.0-dev.20.0 |
fyi - @rakudrama @fishythefish |
Hmm, looks like we're discarding the type argument in the backend somewhere:
This is the case even if the |
At the very beginning the SSA code is missing the type argument. |
This bug stopps us from release a web app. Is there any workaround other then removing |
Taking a deeper look at this now since this is causing NNBD tests to fail. |
function property. Change-Id: I387977e2f1fb7732d94331b7a97cceeec767aaae Bug: #41449 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151301 Reviewed-by: Stephen Adams <sra@google.com> Commit-Queue: Mayank Patke <fishythefish@google.com>
The fix for this is causing test failures on dartdevc firefox dartdevk-checked-linux-release-firefox |
@whesse I'm a little confused by that, since this fix only touches The logs (22443, 23244) are inscrutable to me, so I don't know if this is just flakiness or not. @nshahan, do you know what's going on here? |
There are parts of the test infrastructure that get compiled by dart2js and then used to run tests for DDC so it is technically possible for a dart2js only change to break a DDC bot but that should appear to be an infra failure. These failure logs show DDC stack traces so I'm not sure how your change could be the cause. @whesse Is it possible that they are flakes or did we update the version of firefox running on the bots around the same time this change landed? |
I checked on it, by looking in the results.json for the build after the one they were reported on. This failure has happened a number of times before, and confuses everyone and wastes their time. |
I'm not sure when this will be available in the Repository get repository {
var reader = read;
return reader();
} As this comment mentions, making |
I'm not sure why this is closed as the bug is still happening on the latest version of Dart/Flutter
|
My apologies - I closed the issue when my fix landed and our tests started passing, but it looks like there's still another bug lurking around when |
The initial fix for this was pretty quick, but revealed a deeper issue causing other tests (mainly async ones) to fail. I have a more complete fix that I'm working on landing now. |
Hello guys, any news on this? This is blocking us from releasing a web app on:
Thanks in advance. |
HI @ochmist - the fix landed in 5671730, which is part of Dart's 2.10.0-1.0.dev release and newer releases. I am not sure on which flutter release this version was rolled into. When I try
So the fix should be there. Is the Dart version in your case further behind? Is this resolved after upgrading to the latest flutter? |
Hi @sigmundch, Confirmed that this works well after flutter upgrade. Thank you very much. |
@ochmist what flutter version is working for you (flutter doctor result)? We are also using StateNotifier and our web app is crashing due to this bug.Thanks! @matthewtsmith could you please elaborate on the change you made? I wasn't able to understand the suggestion and how to apply it to our code. |
Actually, after the upgrade it ended up working for a while but breaking soon after. I noticed that once of my dependencies was still outdated and the crash was happening in there. |
To clarify, do you have a repro that still fails with the latest SDK, or is this just a toolchain issue? |
I tried flutter web + riverpod. This code doesn't work.
Then, I built without minify. https://stackoverflow.com/questions/59710360
I can see this log in chrome console.
But this workaround saved me.
|
@fishythefish Can you confirm that this is fixed in the latest SDK? Seems like it is not (from what @ochmist & @takeru reported). Also, we are still experiencing this issue as well. |
(still happens in |
@creativecreatorormaybenot Sorry, I missed this notification earlier. I can't reproduce this issue in the latest SDK when I compile the original example. Do you have a different minimal repro that continues to fail? (I don't work on flutter, so the less flutter-specific, the easier it is for me.) |
@fishythefish Using final providerFamily = StateNotifierProvider.autoDispose.family<Foo, Params>((ref, params) {
return Foo();
});
class Foo extends StateNotifier<int> {
Foo(): super(0);
}
class Params {}
void main() {
final container = ProviderContainer();
container.listen(providerFamily); // crashes
} Fixed by: final _family = StateNotifierProvider.autoDispose.family;
final providerFamily =
_family<Foo, Params>((ref, params) {
return Foo();
});
// ... I do not have the time to test it right now. This is a simplified version of what we have in our app, so if the bug depends on some kind of edge case, it might not reproduce it, however, I think it should do so. Let me know if you have any problems reproducing the bug, then I will get back to you later with a fully tested one - I simply wanted to shoot this one at you in order to help asap. |
|
Alternatively you can do: final providerFamily = StateNotifierProvider.autoDispose.family<Foo, Params>((ref, params) {
return Foo();
});
final refProvider = Provider((ref) => ref);
void main() {
final container = ProviderContainer();
final ref = container.read(refProvider);
ref.watch(providerFamily);
} which should crash too |
Both your examples seem to be unrelated to this issue - I'm getting a compile-time type error in each case, not a runtime error or crash due to dart2js. (Both the common front-end to the compiler and dart analyzer report this). |
@fishythefish Sorry for posting the code prior to testing it - I thought it would be helpful and that the concept would be enough. Here are the full steps for reproducing the bug:
import 'package:riverpod/riverpod.dart';
final providerFamily = StateNotifierProvider.autoDispose.family<Foo, Params>((ref, params) {
return Foo();
});
class Foo extends StateNotifier<int> {
Foo(): super(0);
}
class Params {}
void main() {
final container = ProviderContainer();
container.listen(providerFamily(Params())); // crashes in dart2js only
print('console.log');
}
|
Thanks for your patience, @creativecreatorormaybenot. It does look like we're performing an incorrect RTI optimization somewhere and erasing needed type variables. I'm reopening the issue and will investigate when I get a chance. |
Bug: #41449 Change-Id: I5526d3f6d15945bdf2ba0f790e1c803471b139c6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183120 Reviewed-by: Stephen Adams <sra@google.com>
Turns out it was the same issue as before with essentially the same fix, but dart2js needed to do some additional work to properly track |
@fishythefish just upgraded from flutter EDIT: Oops! I'm sorry. It was actually an annoying cloudfare cache that prevent the update from loading. |
@fishythefish thanks for resolving this. How do I get the fix? If I set my Dart version constraints to |
@venkatd Yes, Dart 2.13 should have all the fixes in it. On the Flutter side, I believe this means 2.2 or higher should have the fix as well. |
From rrousselGit/provider#406
@mono0926 found a compilation issue with Dart2js when running:
where the build output behaves differently from debug builds and VM builds.
The issue happens with the following code:
The expected behavior of this code is to print
int
in the console, which it does in debug builds and VM release builds.But when running this code with
flutter -t chrome --release
, this will printdynamic
This causes
InheritedWIdgets
from Flutter to fail to be resolvedThe text was updated successfully, but these errors were encountered: