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

Add resource id names to the heap dump #1297

Closed
pyricau opened this issue Apr 24, 2019 · 4 comments · Fixed by #1663
Closed

Add resource id names to the heap dump #1297

pyricau opened this issue Apr 24, 2019 · 4 comments · Fixed by #1663
Milestone

Comments

@pyricau
Copy link
Member

pyricau commented Apr 24, 2019

Currently we resolve resource id names at analysis time by calling resources.getResourceEntryName(). This works only if the heap dump is analyzed in the same build as where the heap was dumped.

Instead, we can capture the list of ids and names before the heap dump, store that in a static field in memory, then read it from the analyzer (and clear it in memory)

      for (resId in 0 until (1 shl 16)) {
        try {

          // https://android.googlesource.com/platform/frameworks/base/+/master/core/res/res/values/public.xml
          // 0x07070000 for app, 0x01020000 for Android but we don't need that.
          CanaryLog.d(resources.getResourceEntryName(0x07070000 or resId) + " " + resId)
        } catch (ignored: NotFoundException) {
          // Assumption that might break some day: numbers are sequential, starting at 0
          break
        }
      }

We might want to capture this data as a pre dump step.

cc @romainguy @tyvsmith

@pyricau pyricau added this to the 2.0 Next Release milestone Apr 24, 2019
@pyricau pyricau modified the milestones: 2.0-alpha-2, 2.0 Next Release May 21, 2019
@pyricau pyricau modified the milestones: 2.0-alpha-3, 2.0 Next Release Jul 4, 2019
@pyricau pyricau modified the milestones: 2.0-beta-1, 2.0 Next Release Jul 26, 2019
@pyricau pyricau modified the milestones: 2.0-beta-2, 2.0 Next Release Aug 2, 2019
@pyricau pyricau removed this from the 2.0 Next Release milestone Aug 22, 2019
@pyricau
Copy link
Member Author

pyricau commented Nov 14, 2019

Not sure if something changed but this trick doesn't seem to work, I have an app where 0x07070000 doesn't map to any id (cc @romainguy )

@pyricau
Copy link
Member Author

pyricau commented Nov 14, 2019

It looks like numbers in apps aren't sequential anymore.

@mzgreen
Copy link
Contributor

mzgreen commented Dec 7, 2019

Are you saying it doesn't work on Android 10 or in general? There is a pretty new blogpost about this technique https://jebware.com/blog/?p=600

@pyricau
Copy link
Member Author

pyricau commented Dec 7, 2019

oh cool! It's very possible that I messed up, I'll try again with the code from @Jebstuart

pyricau added a commit that referenced this issue Dec 8, 2019
This enables us to know the view id names when displaying a leak trace

Fixes #1297
pyricau added a commit that referenced this issue Dec 10, 2019
This enables us to know the view id names when displaying a leak trace

Implementation based on a [blog article](https://jebware.com/blog/?p=600) from @Jebstuart which itself is based on a [Stack Overflow answer](https://stackoverflow.com/a/6646113/703646).

Fixes #1297
pyricau added a commit that referenced this issue Dec 10, 2019
This enables us to know the view id names when displaying a leak trace

Implementation based on a [blog article](https://jebware.com/blog/?p=600) from @Jebstuart which itself is based on a [Stack Overflow answer](https://stackoverflow.com/a/6646113/703646).

Fixes #1297
@pyricau pyricau added this to the Next release milestone Dec 10, 2019
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 a pull request may close this issue.

2 participants