Skip to content

Bring the call to referrerClient.installReferrer into a thread#1316

Closed
giawa wants to merge 2 commits intofacebook:mainfrom
giawa:refactor/install-referrer
Closed

Bring the call to referrerClient.installReferrer into a thread#1316
giawa wants to merge 2 commits intofacebook:mainfrom
giawa:refactor/install-referrer

Conversation

@giawa
Copy link

@giawa giawa commented Apr 4, 2025

Hello Facebook!

To help us review the request, please complete the following:

  • ✅ sign contributor license agreement
  • ❓ I've ensured that all existing tests pass and added tests (when/where necessary)
  • ✅ I've updated the documentation (when/where necessary) and Changelog (when/where necessary)
  • 🚫 I've added the proper label to this pull request (e.g. bug for bug fixes) (I don't seem to have permission to do this)

Pull Request Details

We have an issue with high ANR rates on our Unity app, and the stack trace points to these two long standing open issues with this SDK:

I am not a Kotlin expert, but it seemed like this was a simple change to bring the call to referrerClient.installReferrer over to a different thread.

Warning

This change assumes it is okay to make the callback from a different thread than tryConnectReferrerInfo. In my brief check of the codebase, this looked okay, but if necessary we may want to bring the callback back to the main thread.

While doing this, I noticed that the try/catch for cleaning up the referrerClient wouldn't work if an exception was thrown from referrerClient.installReferrer, so I moved that cleanup to a finally block instead.

Test Plan

I have run the test app, but cannot test this code quite yet in my own app, as I haven't explored how to bring this over to Unity. I was hoping by starting here with this repository so I could get feedback before trying to get this brought in to the Unity package as well.

If there is something I can do to help test this, please let me know! My goal here is to get the ball rolling with this conversation so that we can address the high ANR rates caused by this SDK.

giawa added 2 commits April 4, 2025 10:51
…t it can't block the main thread with slow binder calls.

See facebook#1039
See facebook/facebook-sdk-for-unity#672

Also bring the cleanup of referrerClient into the try/catch in the thread.  I believe this addresses an existing issue where if the call to referrerClient.installReferrer throws an exception then we never clean up the referrerClient.
@giawa
Copy link
Author

giawa commented Apr 21, 2025

Just checking in to see if there's anything I can do to help with this PR. It would be great to get something like this in to help with ANR rates on Android.

@giawa
Copy link
Author

giawa commented May 14, 2025

@maxalbrightmeta Any chance you or someone on the team is able to take a look?

@github-actions github-actions bot added the Stale label Aug 13, 2025
@github-actions github-actions bot closed this Aug 21, 2025
@giawa
Copy link
Author

giawa commented Aug 21, 2025

@rageandqq Any chance you're able to take a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants