-
Notifications
You must be signed in to change notification settings - Fork 6k
[Android] Convert int in Dart to long instead of int in java.
#39476
Conversation
|
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. |
e0fcb50 to
01bdf81
Compare
|
xref the iOS version of this patch #39331 |
shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java
Show resolved
Hide resolved
shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java
Show resolved
Hide resolved
c324b51 to
78b4ad9
Compare
| */ | ||
| @NonNull | ||
| public abstract PlatformView create(Context context, int viewId, @Nullable Object args); | ||
| public abstract PlatformView create(Context context, long viewId, @Nullable Object args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change. Any advice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard-breaking every plugin that uses platform views is definitely a non-starter.
Is there some real problem that we need this change to solve? From what I see in the PR description and the issue, it's entirely a theoretical concern, rather than something that has actually caused problems. Presumably there are no Flutter apps that need more than several billion platform views over the life of the app, and I'm having a hard time imagining a scenario where some kind of non-sequential random mapping over more than the range of int would be required.
If this is all just theoretical, the easy solution would seem to be to throw if the value is too large, and document+assert on the Dart side that the value must be within the range of int.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(E.g., it's also the case that on the Dart side setSize on a platform view takes a Size, whose width and height are doubles, but I'm willing to bet that passing double.maxFinite for both would not end well. It's common for APIs to not accept every value that the types could allow for.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, This is not a problem in practice, and given the breaking change, I am also more inclined to the solution you proposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, exposing the |viewId| to the user doesn't seem to make much sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realized this was breaking. Stuart's suggestion seems like it is a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realized this was breaking. Stuart's suggestion seems like it is a good idea.
Sorry, that's my mistake. The breaking change is not obvious, and I forgot to mark it at the beginning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have submitted a new PR. Please review it when you have time. Thank you.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
shell/platform/android/test/io/flutter/plugin/platform/PlatformViewsControllerTest.java
Show resolved
Hide resolved
78b4ad9 to
ccfedc8
Compare
|
@reidbaker Please take another look when you have a moment. Thanks. |
|
Can we land this? @0xZOne is a part of the Flutter org so the presub requirements are satisfied. |
stuartmorgan-g
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current version still has a breaking change to PlatformViewFactory, so can't be landed as is. Setting review state to capture that.
|
Closing it as I have filed a new PR based on the review results. |
We should use the 64-bit to represent
intin Dart.As an example of an extreme case, if |viewId| is greater than
0x80000000on the Dart side, the native code will throw the following exception:See the below codes for more details:
https://github.com/flutter/flutter/blob/19dfde6989b14bd7dedbc50d7edceef4e59879a4/packages/flutter/lib/src/services/message_codecs.dart#L399-L407
Related issue: flutter/flutter#120256
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.