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

.scrollTo() gets stuck on Android #2787

Closed
Sonakshi997 opened this issue May 21, 2021 · 48 comments · Fixed by #4327
Closed

.scrollTo() gets stuck on Android #2787

Sonakshi997 opened this issue May 21, 2021 · 48 comments · Fixed by #4327

Comments

@Sonakshi997
Copy link

Describe the bug

I've been using detox from last few months and this issue came into my observation. On the simulator I cannot see any motion of the scroller. I do not understand any reason for it to not work properly.
Can it be the detox version issue?
The scroller was earlier working in all the test files so far till past 2 weeks and now failing in few of the files.

The testing screen halts when .scrollTo('top') action statement arises and nothing happens afterwards.
If anyone have any solution to this, please share. It would be of great help.

Screenshot 2021-05-20 at 6 16 12 PM

Steps To Reproduce

  1. detox test -c debug

Expected behavior

Should have scrolled the screen in either direction.

Detox Trace-Logs

Log_trace
Log_trace_1
Log_trace_2

Full log trace ->
test_log_trace.pdf

Environment :

  • Detox: 18.7.0
  • React Native: 0.63.3
  • Node: 14.16.0
  • Device: Pixel_API_23x86
  • OS: macOS Big Sur 11.2.3
  • Test-runner: jest-circus
@d4vidi
Copy link
Collaborator

d4vidi commented May 23, 2021

@Sonakshi997 it's really hard to tell what wrong this way. Could you please use the --take-screenshots all, --record-video all and --record-logs all arguments to detox test and provide the artifacts generated under the artifacts/ folder?

Also, before doing so, please also add logs before, after and in between the scrollTo() calls, using console.log.

Thanks.

@Sonakshi997
Copy link
Author

Sonakshi997 commented May 26, 2021

@d4vidi I understand. Here is what you asked for. I hope the issue gets clear now as I am facing this on various different screens now. Also, the ScrollTo() works perfectly fine on IOS.

What is expected from the ScrollTo() -> Done manually:

Expected.Behavior.Of.ScrollTo.mov

What Detox is doing via test:

ScrollTo.is.Stuck.mov

Console Logs Before and After the ScrollTo() :

ConsoleLogsForScrollTo()

What happens on the terminal -

ConsoleLogs Output

This keeps on coming on the terminal and takes a lot of time to even end the test suite.

Thank you.

@d4vidi
Copy link
Collaborator

d4vidi commented May 31, 2021

@Sonakshi997 this is great, thank you. Please also spot a file called process.log under the failing test and upload it as well. Thank you!

@Sonakshi997
Copy link
Author

I understand @d4vidi . I tried finding this file, but could not. Can you describe in detail where can I find this file. That will help a lot.

@d4vidi
Copy link
Collaborator

d4vidi commented Jun 2, 2021

Apply the --record-logs all argument when running detox test. After the execution completes, you will have such files under an artifacts/ subdirectory.

@Sonakshi997
Copy link
Author

Sonakshi997 commented Jun 21, 2021

Hi @d4vidi . Here is the process.log file you requested. Let me know if anything else is required from my side. I can see this scrollTo() issue in various more files. I hope it gets resolved soon.

process.log

Thanks.

@Sonakshi997
Copy link
Author

Hi @d4vidi . I was able to overcome this stuck .scrollTo() problem by doing this.

I created a function that takes the testID as arguments and calls it in files where my scrollTo() does not work.

await element(by.id(scroller_testID)).scroll(scrollValue, 'down')
await element(by.id(scroller_testID)).tapAtPoint({
  x: 10,
  y: 10,
})
await element(by.id(screenView_testID)).tapAtPoint({
    x: 10,
    y: 20,
  })

I believe this is just a temporary solution or a hack to make things work for now. Let me know if there is any progress at your part.
Thank you.

@d4vidi
Copy link
Collaborator

d4vidi commented Jul 19, 2021

Yikes. There shouldn't be such hacks in Detox. @jonathanmos could we get to the bottom of this together?

@stale
Copy link

stale bot commented Aug 18, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Aug 18, 2021
@stale
Copy link

stale bot commented Aug 26, 2021

The issue has been closed for inactivity.

@stale stale bot closed this as completed Aug 26, 2021
@d4vidi d4vidi removed the 🏚 stale label Aug 29, 2021
@d4vidi d4vidi reopened this Aug 29, 2021
@d4vidi
Copy link
Collaborator

d4vidi commented Aug 29, 2021

@jonathanmos were you able to make any progress here?

@stale
Copy link

stale bot commented Sep 28, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.

Thank you for your contributions!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Sep 28, 2021
@d4vidi d4vidi removed the 🏚 stale label Oct 3, 2021
@jonathanmos
Copy link
Contributor

@Sonakshi997 I was not able to reproduce this issue, except when the soft keyboard was open due to typing in the textfield - in which case, I added tapReturnKey to dismiss it and the test subsequently passed properly. What is the purpose of tapAtPoint? Is it to dismiss the keyboard or for another reason?

@no-response
Copy link

no-response bot commented Oct 11, 2021

This issue has been automatically closed because there has been no response to our request for more information from the original author.

For more information on bots in this reporsitory, read this discussion.

@no-response no-response bot closed this as completed Oct 11, 2021
@AdamTyler
Copy link

I'm seeing this exact issue. Works fine on iOS but Android hangs until timing out on scrollTo actions:

detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] INFO:  [APP_STATUS] App synchronization debug: The app appears to be idle!
detox[15977] WARN:  [PENDING_REQUESTS] The app has not responded to the network requests below:
  (id = 50) invoke: {"target":{"type":"Class","value":"com.wix.detox.espresso.EspressoDetox"},"method":"perform","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"androidx.test.espresso.Espresso"},"method":"onView","args":[{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxMatcher"},"method":"matcherForTestId","args":["create-event-preview-post"]}}]}},{"type":"Invocation","value":{"target":{"type":"Class","value":"com.wix.detox.espresso.DetoxViewActions"},"method":"click","args":[]}}]}```

@Sonakshi997
Copy link
Author

@Sonakshi997 I was not able to reproduce this issue, except when the soft keyboard was open due to typing in the textfield - in which case, I added tapReturnKey to dismiss it and the test subsequently passed properly. What is the purpose of tapAtPoint? Is it to dismiss the keyboard or for another reason?

Yes, after typing on an input field, to dismiss the keyboard I used tapAtPoint(which works fine). But here the issue comes after when I think, on applying scollTo('direction') it should go in either direction, but rather the screen stays still. The console shows me initially it is busy with threads and then app is idle comes 'n' number of times and on the UI nothing happens. Just still. No particular reason I could find too for the screen stuck as there was no interruption at the screen as well.

@owens-ben
Copy link

owens-ben commented Sep 7, 2023

This is STILL not fixed.

I cannot understand the logic of closing issues for inactivity, when the developers are the ones who are the ones who are inactive. This makes Detox essentially worthless for Android development. Is that not a priority? Serious question.

@owens-ben
Copy link

owens-ben commented Sep 8, 2023

Anyone else running into this could consider this workaround

if (device.getPlatform() !== 'ios') {
    const scrollView = element(by.type('android.widget.ScrollView'));
    try {
      if (direction === 'bottom') {
        await scrollView.swipe('up'); // swiping up scrolls down
    } else if (direction === 'top') {
        await scrollView.swipe('down');
    }
    } catch (e) { 
      console.error(e)
    }
  }

@cassiourugit
Copy link

I have the same problem. But none of the suggested fixes did it for me.
Simply unable to use detox on android because any of the drag, swipe, scroll gestures work.
Everything fine on IOS...

I wonder why there is not more people with this issue, should be a very common issue to bump into

@markpar
Copy link

markpar commented Oct 16, 2023

I tried adding flex: 1 to the style for the parent container and it seems to be working so far. We have a lot of scrollable screens in our app and I'll need to verify them all, but confidence is high.

Long term, it would be nice to understand why that workaround unblocks things and, if possible, make a fix for it. Happy to help out in any way I can.

Ahhhh crud, I was using an Android 11 phone when I thought I was using an Android 13 one. Adding flex: 1 to the style of the parent container didn't change anything, unfortunately. Still happy to help out!

@noomorph
Copy link
Collaborator

To the all interested parties, please try out detox@20.13.2-smoke.0.

Thanks to @patriksletmo for providing an experimental hotfix. 🏆

Let's find out if it solves your issues with the scrolling or swiping - please give us and @patriksletmo some feedback.

cc @poojan010, @celian-rib, @seth-nelson, @klcantrellsep (you placed only emojis on the messages, so I'm just making sure you see this update)

@noomorph
Copy link
Collaborator

Any updates about 20.13.2-smoke.0?

@poojan010
Copy link

Any updates about 20.13.2-smoke.0?

Did not work

@noomorph
Copy link
Collaborator

@poojan010 would you mind to record a video artifact with an example of what's happening there on a scroll attempt?

@poojan010
Copy link

sure i'll provide video today

@Seraphiyra
Copy link

Any updates about 20.13.2-smoke.0?

I've just given this a shot in hope this might help with some of the issues we have been running into with android.

Seems to have resolved the issue with scroll getting stuck, but we are still seeing swipe getting stuck in the same way.

@noomorph
Copy link
Collaborator

@Seraphiyra well, as long as it does not break something and fix something, it is good for me to release. Thanks for the confirmation!

If someone can fiddle with our Android source for swipe handlers, similarly to #4225, please share your solution. We'll make sure to release a public beta as soon as you submit and it passes our E2E tests.

@poojan010
Copy link

Not working for Me

Screen.Recording.2023-10-24.at.11.11.32.AM.mov

simple.test.js

describe('Example', () => {
  beforeAll(async () => {
    await device.launchApp();
  });

  beforeEach(async () => {
    // await device.reloadReactNative();
  });

  it('scroll to bottom', async () => {
    await element(by.id('scroll-view')).scrollTo('bottom');
  });

  it('scroll to top', async () => {
    await element(by.id('scroll-view')).scrollTo('top');
  });
});

App.js

import { Button, ScrollView, StyleSheet, Text, View } from 'react-native'
import React from 'react'

const App = () => {
  return (
    <View style={{flex:1,backgroundColor:'white'}}>
      <ScrollView testID='scroll-view' style={{ flex: 1}}>
        <Text testID='hello-text'>Hello</Text>
        <View  style={{height:500}}/>
        <View  style={{height:500}}/>
        <Button title='Press Me' testID='button'/>
        <View  style={{height:500}}/>
        <View  style={{height:500}}/>
      </ScrollView>
    </View>
  )
}

export default App

const styles = StyleSheet.create({})

@noomorph
Copy link
Collaborator

@poojan010 , what is happening here? 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯
🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯
🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯

Do I understand correctly that a scroll gesture is interpreted as some system UI action, and it gets interpreted by Android itself? If so, I wonder, can't you disable some gestures on your emulator?

@noomorph
Copy link
Collaborator

noomorph commented Oct 24, 2023

I had a busy day today, so I'd refrain from releasing when I'm leaving the office. Tomorrow I'll release that smoke version.

UPD: A partial fix was released in detox@20.13.3

@Seraphiyra
Copy link

@Seraphiyra well, as long as it does not break something and fix something, it is good for me to release. Thanks for the confirmation!

If someone can fiddle with our Android source for swipe handlers, similarly to #4225, please share your solution. We'll make sure to release a public beta as soon as you submit and it passes our E2E tests.

@noomorph I had a little bit of a poke into this, but alas no success😞

I tried a few things, but in the end by changing from API 33 -> 32 was able to get swipe to work for us again. This was a not ideal, albeit quick, fix to enable us to keep our tests running and not block releases.

We currently use significantly more swipe actions than scroll actions in our test suite. So that means this will go into my backlog to poke at again (if others don't fix beforehand 🤞)

@noomorph
Copy link
Collaborator

@Seraphiyra, thanks for trying! I hope someone takes it soon. I communicated the importance of these issues to my team, but the ETA is not clear yet.

@noomorph
Copy link
Collaborator

@poojan010 I think that @gosha212 will look quite soon into your case. There's a plan to fix scroll/swipe conflicting with Android's gesture handling.

@gosha212
Copy link
Contributor

Hi @poojan010,
I'm working on a solution for your problem. A temporary solution is to disable the gesture navigation on your emulator. Here is more details:

@gosha212 gosha212 self-assigned this Jan 2, 2024
gosha212 added a commit that referenced this issue Jan 4, 2024
Fixing scroll interfere with system gesture navigation on android 33-34
@gosha212 gosha212 linked a pull request Jan 4, 2024 that will close this issue
2 tasks
@hanna-becker
Copy link

hanna-becker commented Jan 5, 2024

Ran into this issue today, the workaround of adding style={{flex: 1}} to the parent view fixes the scrollTo command for us.

Android API 30, detox 20.14.8

Hope there'll be a proper fix, soon!

@d4vidi d4vidi self-assigned this Jan 7, 2024
gosha212 added a commit that referenced this issue Jan 10, 2024
…android

Bugfix/2787 scrollto gets stuck on android 
Fixes #2787 and  #4312
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.