jraska/Falcon

Impossible to capture shadows around components

thomaschampagne opened this issue · 3 comments

Hi @jraska,

We dig into your library last week to take screenshots in our android app. You've done an amazing work and results are almost perfect for us.

We were not able to capture shadows around material components: Card, Floating Action Buttons, ... (https://material.io/develop/android/).

On a generic aspect, did you try to capture shadows? Is this something technically possible for you?

Thanks for your work and help!

Thomas

Hello Thomas,

It's great to here the library works for you, even if it is almost :D

I'm not sure if it is possible. What Falcon is doing is it grabs all the windows of the app like dialogs and screen itself and then draws these views into bitmap here:

If from some reason shadows do not appear, it is because View hierarchy does not draw them into provided Canvas. No idea what is the reason, maybe shadows are handled by another mechanism then just the View hierarchy, I don't know.

I may try to investigate this once i have some time, but if the Views themselves do not draw the shadows by themselves, only possible solution how to fix this may be finding the mechanism to draw shadows and try to hook into it, but no idea if that is possible.

I hope it makes sense. If you will have any insights into this please let me know. I will keep the issue open now to not forget, but now I'm a bit pessimistic until some research is done.

Hello, after finally looking into that I found following:
Shadows are hardware accelerated, therefore the View hierarchy caching, which is Falcon using by drawing method into Canvas. I found that out here and it makes perfect sense I just didn't realise it before.

Therefore I'm sorry, but capturing shadows is currently impossible for Falcon. Not sure what are your use cases, but maybe Media Projection API can help.

@jraska Thanks for your investigation !