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

[BUG] stop shipping aidl implementation headers in the NDK #1307

Closed
atsushieno opened this issue Jul 4, 2020 · 8 comments
Closed

[BUG] stop shipping aidl implementation headers in the NDK #1307

atsushieno opened this issue Jul 4, 2020 · 8 comments
Assignees
Labels

Comments

@atsushieno
Copy link

Description

There was an API breaking change that was suddenly introduced at NDK 21.3..6528147, and to make it worse, this breaks ANY native binder service implementation derived from BnCInterface which is automatically generated by aidl(.exe).

$ diff -ur ~/Android/Sdk/ndk/21.2.6472646/sysroot/usr/include/ ~/Android/Sdk/ndk/21.3.6528147/sysroot/usr/include/ | grep SharedRefBase
     std::weak_ptr<SharedRefBase> mThis;
+    // Use 'SharedRefBase::make<T>(...)' to make. SharedRefBase has implicit

The problematic file is binder_interface_utils.h.

With NDK 21.3..6528147, it became simply impossible to define a service implementation class that is derived from the abstract class for the AIDL generated by aidl(.exe), because the generated class itself is abstract and therefore SharedRefBase::make() does not accept it. And we cannot define the derived class without making appropriate base constructor to BnCInterface which is now simply impossible.

To my understanding, this new operator must not be defined at SharedRefBase.

As long as I searched for any usage of BNCInterface at cs.android.com, it is totally untested. https://cs.android.com/search?q=BNCInterface

Environment Details

Not all of these will be relevant to every bug, but please provide as much
information as you can.

  • NDK Version: 21.3.6528147
  • Build system: sysroot/usr/include
  • Host OS: Linux (Ubuntu 20.04)
  • ABI: i686 (should be any)
  • NDK API level: 29
  • Device API level: 29 (should be irrelevant)
@DanAlbert
Copy link
Member

The API owner will be responding with a useful answer in a bit, but it sounds like the immediate action to be taken here is for me to revert https://android-review.googlesource.com/c/platform/frameworks/native/+/1235494 in the r21 branch to restore API compatibility within the major release. This got included along with the rest of the R APIs.

@smore-lore
Copy link

smore-lore commented Jul 6, 2020

Thank you for reporting this issue.

In your search, you can see the AIDL compiler code, and in the various tests of this compiler, we ensure compatibility between the binder NDK. The main test in platform for this code is CtsNdkBinderTestCases, but it is also used extensively.

The problem here is a mismatch between the AIDL compiler and the binder NDK. Specifically, these two changes were made in Android 11:
https://android-review.googlesource.com/c/platform/frameworks/native/+/1235494
https://android-review.googlesource.com/c/platform/system/tools/aidl/+/1234468

As you can see, you have the latest NDK headers, but not the latest version of AIDL, but this shouldn't be a problem you need to deal with. The plan is to revert the NDK API change, and file a separate platform issue to ensure this type of mismatch doesn't happen again. Thanks!

edit: forward looking platform issue filed at http://issuetracker.google.com/160624671

@DanAlbert
Copy link
Member

A question that came up while discussing this, how are you actually consuming this? @smore-lore says that AGP doesn't have support for NDK aidl. Do you have your own build system that does support it?

@atsushieno
Copy link
Author

Not really; I rarely update the API, so I check in the generated code along with the aidl file, and whenever I need it I simply run a shell script that only runs aidl tool.

@DanAlbert
Copy link
Member

I see. Well, speaking with @smore-lore today I believe the short term fix for you is to use an up to date version of aidl. The problem is that there's unwanted coupling between the headers in the NDK and the aidl compiler. The issue you're running into is that you're using an older version of aidl with the new headers. If you use an aidl from build-tools 30 it should work. Let us know if it doesn't.

@atsushieno
Copy link
Author

I should have included the build-tools version... it was with 30.0.0. I'm seeing #ifdef BINDER_STABILITY_SUPPORT which I believe is new in the latest version. I'm not sure if loosely-coupled build-tools/aidl version vs. NDK API is very problematic...maybe it would be acceptable to most people if appropriate coding workaround is available, I guess.

In the meantime I can stay with older NDK setup until the fix lands in newer versions (it's actually kind of complicated; I also use GitHub Actions which always removes older NDKs from the image, which I don't think is a good idea...). Thanks for the hint on possible workaround anyways.

@atsushieno
Copy link
Author

atsushieno commented Oct 26, 2020

I believe the forementioned issue is fixed in build-tools r30.0.2. Maybe this can be closed as well?

Edit: I revisited the actual issue comment 654437828 and noticed that having up-to-date build-tools is not an expected fix for you teams. But as the comment on the issue above says, the problem itself is fixed appropriately anyways.

@DanAlbert
Copy link
Member

DanAlbert commented Oct 26, 2020

We're still waiting to get the fix that defends against the problem recurring into r21. Will close after that.

@DanAlbert DanAlbert removed this from the r21e milestone Feb 2, 2021
@DanAlbert DanAlbert changed the title [BUG] API breaking change in 21.3.6528147: SharedRefBase must not define operator "new" [BUG] stop shipping aidl implementation headers in the NDK Oct 17, 2022
@DanAlbert DanAlbert added this to NDK r28 Sep 5, 2024
@github-project-automation github-project-automation bot moved this to Unconfirmed in NDK r28 Sep 5, 2024
@DanAlbert DanAlbert moved this from Unconfirmed to Merged in NDK r28 Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Merged
Development

No branches or pull requests

4 participants
@atsushieno @DanAlbert @smore-lore and others