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

2.0.0 To 2.1.0, realm_core.dart Function _createConfig changed #1647

Closed
PaniniA opened this issue Apr 24, 2024 · 14 comments · Fixed by #1648
Closed

2.0.0 To 2.1.0, realm_core.dart Function _createConfig changed #1647

PaniniA opened this issue Apr 24, 2024 · 14 comments · Fixed by #1648

Comments

@PaniniA
Copy link

PaniniA commented Apr 24, 2024

What happened?

Attempt to execute code removed by Dart AOT compiler (TFA)

Repro steps

await Realm.open(config). then Attempt to execute code removed by Dart AOT compiler (TFA)

Version

2.1.0

What Atlas Services are you using?

Local Database only

What type of application is this?

Flutter Application

Client OS and version

iOS 17.2

Code snippets

2.1.0 code
// final schemaVersion = switch (config) {
// (LocalConfiguration lc) => lc.schemaVersion,
// (FlexibleSyncConfiguration fsc) => fsc.schemaVersion,
// _ => 0,
// };
// _realmLib.realm_config_set_schema_version(configHandle._pointer, schemaVersion);

2.0.0 code
_realmLib.realm_config_set_schema_version(configHandle._pointer, config is LocalConfiguration ? config.schemaVersion : 0);

Stacktrace of the exception/crash you're getting

No response

Relevant log output

No response

Copy link

sync-by-unito bot commented Apr 24, 2024

➤ PM Bot commented:

Jira ticket: RDART-1014

@nielsenko
Copy link
Contributor

To me this seems like a compiler issue. I'm not sure how we can provoke that. Have you tried doing flutter clean and then retry the build?

@PaniniA
Copy link
Author

PaniniA commented Apr 24, 2024

对我来说,这似乎是一个编译器问题。我不确定我们如何能激怒那个。你有没有试过做flutter clean,然后重试构建?

To me this seems like a compiler issue. I'm not sure how we can provoke that. Have you tried doing flutter clean and then retry the build?

I tried doing flutter clean, But it didn't solve my problem。

@PaniniA
Copy link
Author

PaniniA commented Apr 24, 2024

To me this seems like a compiler issue. I'm not sure how we can provoke that. Have you tried doing flutter clean and then retry the build?

2.1.0 code
// final schemaVersion = switch (config) {
// (LocalConfiguration lc) => lc.schemaVersion,
// (FlexibleSyncConfiguration fsc) => fsc.schemaVersion,
// _ => 0,
// };
// _realmLib.realm_config_set_schema_version(configHandle._pointer, schemaVersion);

2.0.0 code
_realmLib.realm_config_set_schema_version(configHandle._pointer, config is LocalConfiguration ? config.schemaVersion : 0);

I changed the code from 2.1.0 to 2.0.0 and solved my problem.

the problem : Attempt to execute code removed by Dart AOT compiler (TFA)

@nielsenko
Copy link
Contributor

I read your report. But the new code is just fine. The compiler should not remove it during tree-shaking. To my knowledge you are the only one with this problem. What version of flutter are you using?

@PaniniA
Copy link
Author

PaniniA commented Apr 24, 2024

我读了你的报告。但新代码很好。编译器不应在摇树时删除它。据我所知,你是唯一有这个问题的人。你使用的是哪个版本的flutter?

3.13.9

@PaniniA
Copy link
Author

PaniniA commented Apr 24, 2024

I read your report. But the new code is just fine. The compiler should not remove it during tree-shaking. To my knowledge you are the only one with this problem. What version of flutter are you using?

I don't think dart will execute switch code when it compiles, you should use triadic arithmetic, my English is terrible,sorry

@PaniniA
Copy link
Author

PaniniA commented Apr 24, 2024

I read your report. But the new code is just fine. The compiler should not remove it during tree-shaking. To my knowledge you are the only one with this problem. What version of flutter are you using?

like a==1 ? (b==1 ? 1: 0) : 0

@nielsenko
Copy link
Contributor

Switch expressions was added in Dart 3. Flutter 3.13.9 uses Dart 3.1.5.

@nielsenko
Copy link
Contributor

All our tests pass with flutter 3.19.3 / dart 3.1.5 and realm 2.1.0 - on my machine.

Could you try creating a new project, add the realm package, and see if the issue exists with the new project?

@PaniniA
Copy link
Author

PaniniA commented Apr 24, 2024 via email

@nirinchev
Copy link
Member

Could you create a simple project that reproduces the issue and share it? As Kasper said, we do have tests that don't exhibit the problem, so having something we can test on will help us get to the bottom of it.

@nielsenko
Copy link
Contributor

@PaniniA This is indeed a bug in the Dart compiler (See dart-lang/sdk#52596). You need to upgrade to at least Dart 3.2.0 which was released together with Flutter 3.16.0.

@nielsenko
Copy link
Contributor

@PaniniA Actually I recommend switching to Flutter 3.19.0 or later to get Dart 3.3.0+ because there is another related issue (that I don't know if we hit).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants