-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
View.getGlobalVisibleRect()
is broken in some use cases
#23870
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There is a blog post titled, Android View Measurement. It provides a very good explanation of
If we take a look at the implementation of
I do not have particular opinions about this Android API. But I can understand why, from a performance perspective, the platform designers would not want to provide a simple method call that does an O(depth) traversal. If you want a method that recursively traverses parent view groups to apply all clippings, it would appear that you can do this by repeatedly calling |
@yungsters I don't think that would be helpful tbh, as, given the existing implementation, I suppose the real question here is whether hard-setting native views' clipping to |
@yungsters @hramos any leads regarding improving / fixing this? |
Ya, any heads up appreciated. As Detox is broken and blocked on RN 0.59+ on Android due to this. |
I do not have any good ideas for how to resolve this. I understand the dilemma that this places on Detox, but I do not know how else we could possibly have implemented support for |
@yungsters, @d4vidi, If I may chime in here, I'm facing the same issue trying to implement an Intersection Observer native component and did a little digging. It seems the implementation in question is in ViewGroup, not ViewRootImpl and it does in fact recurse up the view hierarchy: As such, @yungsters would it not be possible to override this method in ReactViewGroup.java, and instead of testing against getClipChildren(), test the value of mOverflow, or is there some nuance I'm missing? |
Ahhh… good catch. That might indeed work, and I am not aware of any nuance. Checking I don’t know when I’ll personally be able to get to trying this, but would you be willing to send a pull request? |
I've got a proof of concept working with a static re-implementation in my local codebase. I'll see if I can get it working as a proper override in ReactViewGroup and issue a PR. (Might have to go through a few local approvals; this is for a work project, but there is precedent for us contributing to RN, so it shouldn't be a problem) |
@davidbiedenbach if you manage to do so it would be the best news I got all year :-) |
…VisibleRect() in ReactViewGroup
…VisibleRect() in ReactViewGroup
My apologies for the delay, I've had a bit of parental leave. @d4vidi Here's a screenshot for you to whet your appetite: @yungsters A couple of issues have come up:
|
@yungsters or is it better to get the PR together and discuss there? |
Hilarious 🤣 |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Arise, zombie bug. Arise! |
@yungsters @mdvacca could we get another shot at this? Last time we tried it, @davidbiedenbach's PR was reverted because of an alleged increase of ANR's (see #23870). I think it's important enough so as to try again. Wdyt? |
Hey @d4vidi , finally circling back on this. I see the code hasn't been reverted per se, it's just gated by a feature flag. |
(Also, I think you have the wrong link in your comment... ;-) Here's the merged PR: #26334) |
Yikes, thanks for pointing that out 😄 |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Merry Christmas stale bot! Stale not. |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Still broken (we have automated tests the check that regularly) |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This is still in effect, unfortunately. Could someone please revisit this, maybe retry the solution? We see Detox users getting "hit" by this every now and then. |
Same issue ANR from google play
|
I will implement #26334 and fix this issue. Relevant: wix/Detox#1208 |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Still broken? |
🐛 Bug Report
With respect to the list of these commits - all of which involve child-views clipping on Android (AKA the overflow functionality): b81c8b, 6110a4c, bbdc12e, 9c71952;
While in essence the approach makes sense for introducing overflow toggling support, having view-group components' clip-children flag hard-codedly set to
false
creates undesired side-effects. One of which is the breaking of the logic of the nativeView.getGlobalVisibleRect()
method. In some cases -- as illustrated by the screenshot from a demo app I've worked out for this, the native method will returntrue
for views that were effectively properly clipped byReactViewGroup
, and are in fact not visible on the screen.In that specific use case, while the view-group holding the upper part of the screen (gray background) is limited in height, the scroll view stretches all the way down to the bottom of the screen. This way, items 14..17 are drawn under the lower part of the screen (blue), and - as far as Android is concerned, are NOT clipped by the parent view-group -- as it's clip-children flag is off.
Among other potential functionalities, this stability of the
View.getGlobalVisibleRect()
method is paramount for ui-testing projects to work -- such as https://github.com/wix/Detox (the one I'm working on right now) and that is already integrated into React Native itself (for iOS).To Reproduce
The demo app is available on github
Expected Behavior
View.getGlobalVisibleRect()
should returnfalse
for views that were clipped off by one of their view-group parents.Code Example
From the demo app:
Environment
The text was updated successfully, but these errors were encountered: