-
Notifications
You must be signed in to change notification settings - Fork 84
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
Use StandardCharsets. #2131
Use StandardCharsets. #2131
Conversation
Hi, it will probably be a week or so before I get to look at this. Have you run the Integration / Android tests on the PR yet? Previously when I've tried to use the desugaring support it had failed due to bugs in the Google supplied code (for example ConcurrentHashMap). Which is one of the reasons we haven't switched. |
Not yet. I'll run them tomorrow and see if there are any issues. |
Without a lot of HW the tests take a very long time to run, roughly 30 minutes on 20 parallel emulators, hours if not run in parallel. I'll do it when I'm back home next week. Just wanted to know if you had already gone through the effort. |
I just ran the tests on Android 9 which fails fairly spectacularly (98 fails of 220 tests), so something is wrong somewhere (most likely the additional dex file not being included). I can run the app on a local 9.0 emulator so there's likely not something that is fundamentally wrong in that respect. Just an example
The other, currently less important, niggle is that you reordered the imports, creating a lot of unnecessary noise in the PR. Please sort as follows:
|
Hmm, it seems like in this instance, the
Sure, I'll fix the imports tomorrow. |
The weird thing with the specific error is that this was running on Android 9 SDK 28 which should have native support for Objects.compare in its runtime. This seems to be the root cause for a number of the errors (I haven't checked all 98) as this is used when setting up the menu when multiple elements are selected. |
I haven't done any more work on the testing issue yet, however I've re-encountered the ConcurrentHashMap issue I mentioned. This turns out to be the serialisation library not finding it on Android 4.1 and 4.4 when desugaring is enabled. Wit:
|
Pro memoria list of supported APIs with desugaring https://developer.android.com/studio/write/java11-nio-support-table |
That seems to be due to that section of code being executed before the |
Yes it does. Leaves the testing issue. google is not very clear on if tests should even work with de-sugaring. |
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.
PLS don't merge!
Always rebase on the HEAD of branch you are working relative to, that is in this case master, and then force push your work. This gives us a clean and sequential series of commits.
My bad, I'm used to merging. |
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 should have been squashed with the initial commit and then the whole thing force pushed.
I would suggest using interactive rebase to clean up everything and then force push.
No panic, I got it wrong many times at first. It just makes things far easier for everybody involved. |
Another problem, on 4.1 and 4.4 I run in to this error:
which looked as if it could have a similar cause as (Iterator is de-sugared too) https://issuetracker.google.com/issues/157681341 however setting debuggable to false for the debug build didn't fix the issue. |
c2bdf8e
to
c444f6d
Compare
Maybe |
There would be significant downsides to that, not the least memory and performance wise (it is quite possible to have 10'000 or more entries which is outside of the design parameters of LongSparseArray). Not to mention that the issue effects every implementation of Iterator in the code so changing use in one place is not going to actually achieve anything. |
So the Iterator issue is clearly the same google issue as I mentioned (multiple definitions of the Interface), so it will probably never run in debug mode, which isn't really necessary as we can't/don't do automated testing on anything below Android 8 in any case. So we just have to verify that a release build would work. Update: this isn't looking good, to the point that I would say this is a R8 bug. Medium term we're going to up the min SDK anyway. But not just for this PR it would be nice to get the de-sugaring working now. |
Sorry, but this is not going to work as long as we are supporting 4.1 to 4.4. I've tried multiple different approaches but there doesn't seem to be a way to stop R8 from adding both java.util.Iterator and the de-sugared version Interfaces to the class definition (verified by decompiling the dex files) which causes the runtime on 4.X to bork. The only avenue to resolving this that could be explored that I haven't looked at, is building a custom version of the de-sugaring library that removes the java.util.Iterator de-sugaring. However this would not stop similar issues in other cases, potentially it would be better to work backwards by adding extra classes to the minimal version of the de-sugaring library. |
The master branch has now dropped support for pre-Android 5 devices so this should be able to proceed now. Could you rebase the PR on the current master? |
c444f6d
to
8414540
Compare
8414540
to
1474767
Compare
As is, integration tests fail (and likely normal use would fail too, likely this set of bugs https://issuetracker.google.com/issues/266687543 Potentially this can be fixed by upgrading AGP to 8.2. Nope. As the de-sugaring is not actually necessary for this PR any more, I intend to merge it without it, it would have been nice to get it working, but there are limits to the time we can spend on a nice to have. |
21a35d7
to
2fb9f77
Compare
Use
StandardCharsets
, which is available for API levels below 19 via core library desugaring.