Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@getActivity
Copy link
Contributor

@getActivity getActivity commented Jul 24, 2022

Proposed Changes

Hello, there will be a memory leak when calling activity.shouldShowRequestPermissionRationale in Android 12. The problem is fixed in Android 12L, but it is still a legacy in Android 12. It is recommended to reflect the application.shouldShowRequestPermissionRationale method to avoid this problem.

Testing

Test: manually ran with LeakCanary

ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.CAMERA);
finish();
  • Use leakcanary to view memory leaks

  • Or use profiler to view memory leaks

Please see

IssueTracker 212113500

IssueTracker 207946473

IssueTracker 204539732

Issues Fixed

Fixes: b/212113500

Fixes: b/207946473

Fixes: b/204539732

@liutikas liutikas requested a review from alanv July 25, 2022 16:53
@alanv
Copy link
Member

alanv commented Aug 2, 2022

Presubmit is unhappy because there's no Test: stanza in the commit message.

Please update your PR message to use Bug: <bug-id> or Fixes: <bug-id> for the bug numbers addressed and Test: <class-name> for the test added, as in #428

@getActivity
Copy link
Contributor Author

@alanv Thanks for the reminder, the revision has been completed

@alanv
Copy link
Member

alanv commented Aug 3, 2022

Still needs a Test: stanza. Given that we're not adding LeakCanary to the CI tests, I think Test: manually ran with LeakCanary is appropriate.

@getActivity
Copy link
Contributor Author

Still needs a Test: stanza. Given that we're not adding LeakCanary to the CI tests, I think Test: manually ran with LeakCanary is appropriate.

@alanv Hello, I have made the modification here as required.

@alanv alanv self-assigned this Aug 4, 2022
@getActivity
Copy link
Contributor Author

@liutikas @alanv Hello, what is the problem with the merge code?

@getActivity
Copy link
Contributor Author

@tikurahul @alanv @liutikas Hello, this problem seems to be difficult to solve, do I need to initiate a new pull request?

@alanv
Copy link
Member

alanv commented Aug 11, 2022

If @dlam and @tikurahul can't get this working, our GitHub workflow is busted. Let's keep pushing on this PR.

@tikurahul
Copy link
Collaborator

I added some additional logging in the check-pr-format-action. @getActivity Did you actually change the commit message to include the Test stanza as well ? GitHub lets you change it after you make the PR, but that does not change the underlying commit message. One thing that might help is to git commit --amend with the Test stanza and do a force push so the action is forced to pick up all the new changes.

…-leak

# Conflicts:
#	core/core/src/main/java/androidx/core/app/ActivityCompat.java
@getActivity
Copy link
Contributor Author

@tikurahul Hello, I have modified the commit message as required, can you take a look again?

@tikurahul
Copy link
Collaborator

Kicking off another workflow run ! It moved past the point of last failure. So its promising 🤞🏽

@getActivity
Copy link
Contributor Author

image

@getActivity
Copy link
Contributor Author

@tikurahul Hello, I found a code check failure here, will this affect code merging?

@dlam
Copy link
Member

dlam commented Aug 16, 2022

@tikurahul Hello, I found a code check failure here, will this affect code merging?

> Task :core:core:lintDebug FAILED
/home/runner/work/androidx/androidx/core/core/src/main/java/androidx/core/app/ActivityCompat.java:830: Error: Calling Method.invoke without an SDK check [BanUncheckedReflection from androidx.build]
                return (boolean) method.invoke(packageManager, permission);
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   Explanation for issues of type "BanUncheckedReflection":
   Jetpack policy discourages reflection. In cases where reflection is used on
   platform SDK classes, it must be used within an SDK_INT check that
   delegates to an equivalent public API on the latest version of the
   platform. If no equivalent public API exists, reflection must not be used.

This is a real error that you need to fix. @alanv can probably advise on best way to go about it.

@getActivity
Copy link
Contributor Author

@alanv Hello, do you have any good advice on this issue?

@getActivity
Copy link
Contributor Author

@tikurahul @dlam @liutikas Do you guys have any good solutions?

@getActivity
Copy link
Contributor Author

@alanv @tikurahul @dlam @liutikas Hi, I see @SuppressLint("BanUncheckedReflection") is used in AndroidX code to suppress reflection warnings, can I add @SuppressLint("BanUncheckedReflection") to avoid this issue?

@alanv
Copy link
Member

alanv commented Aug 26, 2022

@alanv @tikurahul @dlam @liutikas Hi, I see @SuppressLint("BanUncheckedReflection") is used in AndroidX code to suppress reflection warnings, can I add @SuppressLint("BanUncheckedReflection") to avoid this issue?

Yes, this can be suppressed since the call site is wrapped with an SDK_INT check.

@getActivity
Copy link
Contributor Author

@alanv Hello, I have submitted the modification of this part of the code

@getActivity
Copy link
Contributor Author

@alanv Hello, please check whether there are any problems with the changes, if there are any, please point out, if not, please approve them

@alanv alanv merged commit 7168829 into androidx:androidx-main Aug 31, 2022
@getActivity getActivity mentioned this pull request Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants