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

Disabling animation synchronisation on iOS #488

Closed
ndillon1 opened this issue Jan 5, 2018 · 10 comments
Closed

Disabling animation synchronisation on iOS #488

ndillon1 opened this issue Jan 5, 2018 · 10 comments

Comments

@ndillon1
Copy link

ndillon1 commented Jan 5, 2018

Description

When running test on iOS, errors are thrown for javascript timers on the main thread. Documentation states that animation synchronisation can be turned off but does not specify how.

Is there a formal way of turning off animation synchronisation ?

  • Detox: 6.0.4
  • Node: 8.4.0
  • Device: iPhone 7 - iOS11
  • Xcode: 9.2.0
  • macOS:

Device and verbose Detox logs

detox info Sync WXRunLoopIdlingResource: React Native thread is busy.
detox info Sync WXAnimatedDisplayLinkIdlingResource: undefined
detox info Sync JavaScript Timers: Javascript Timers Ids: 444
detox info Sync App State: Waiting for an animation to finish. Continuous animations may never finish and must be stopped explicitly. Animations attached to hidden view may still be running in the background.
detox info Sync Waiting for network requests to finish.
detox info Sync Waiting for view's draw or layout pass to complete.: (
detox info Sync     "http://localhost:8081/assets/app/assets/images/card-dummy@2x.png?platform=ios&hash=0681e25e9fbb3bfb14bf639eeb245a1d",
detox info Sync )
detox info Sync Dispatch Queue: com.apple.main-thread
detox verb ws send: {"type":"currentStatus","params":{},"messageId":24}
detox verb ws onMessage: {"type":"currentStatusResult","messageId":24,"params":{"state":"busy","resources":[{"name":"JavaScript Timers","info":{"javascriptTimerIDs":[874],"prettyPrint":"Javascript Timers Ids: 874"}},{"name":"Dispatch Queue","info":{"queue":"<OS_dispatch_queue_main: com.apple.main-thread[0x11315cdc0] = { xref = -2147483648, ref = -2147483648, sref = 1, target = com.apple.root.default-qos.overcommit[0x11315e300], width = 0x1, state = 0x001ffe9e00000400, dirty, max qos 6, in-flight = 0, thread = 0x403 }>","prettyPrint":"com.apple.main-thread"}}],"messageId":24}}
detox verb ws
detox info Sync JavaScript Timers: Javascript Timers Ids: 874
detox info Sync Dispatch Queue: com.apple.main-thread
detox verb ws send: {"type":"currentStatus","params":{},"messageId":25}
detox verb ws onMessage: {"type":"currentStatusResult","messageId":25,"params":{"state":"busy","resources":[{"name":"JavaScript Timers","info":{"javascriptTimerIDs":[936],"prettyPrint":"Javascript Timers Ids: 936"}},{"name":"Dispatch Queue","info":{"queue":"<OS_dispatch_queue_main: com.apple.main-thread[0x11315cdc0] = { xref = -2147483648, ref = -2147483648, sref = 1, target = com.apple.root.default-qos.overcommit[0x11315e300], width = 0x1, state = 0x001ffe9e00000400, dirty, max qos 6, in-flight = 0, thread = 0x403 }>","prettyPrint":"com.apple.main-thread"}}],"messageId":25}}
detox verb ws
@rotemmiz
Copy link
Member

rotemmiz commented Jan 8, 2018

await device.disableSynchronization(); will disable all synchronization.

@ndillon1
Copy link
Author

ndillon1 commented Jan 9, 2018

@rotemmiz is there no method to just disable animation synchronisation rather than the entire synchronisation engine ?

See below for the documentation which implies that this may be possible

Endless looping animations
By default, Detox will wait until animations complete. If you have an endless looping animation,
this may cause Detox to hang. In this case, consider turning off the animation synchronisation...

Also Earl Grey has this method to alter the animaton timeout, will detox support this?
[[GREYConfiguration sharedInstance] setValue:@(30.0)forConfigKey:kGREYConfigKeyCALayerMaxAnimationDuration];

@LeoNatan
Copy link
Contributor

LeoNatan commented Jan 10, 2018

I don't think we exposed the EG configurations to Detox.

But I doubt that configuration will be at any help in your case.

RN does not use system animations (React "Native"); it either uses timers (yuck) or its own native animation implementation (useNativeDriver). In the timers case, there isn't much we can do to differentiate between legit app timers and animation timers. We do some logic to try and minimize false positives, but there will always be cracks to fall through.

Are you using Animated? If so, try setting useNativeDriver to true and see if that helps.

@ndillon1
Copy link
Author

ndillon1 commented Jan 18, 2018

@LeoNatan @rotemmiz
I have used useNativeDriver for all animations present however I still receive this stack trace when debugging synchonization

Timed: animateWithDuration:delay:options:animations:completion:
detox info Sync Timed: animateWithDuration:delay:options:animations:completion:
detox info Sync WXAnimatedDisplayLinkIdlingResource: undefined
detox info Sync Dispatch Queue: com.apple.main-thread
detox info Sync WXAnimatedDisplayLinkIdlingResource: undefined
detox info Sync Dispatch Queue: com.apple.main-thread
detox info Sync WXAnimatedDisplayLinkIdlingResource: undefined

What else can be done to remove these errors ?

@pietropizzi
Copy link
Contributor

I'm running into something similar too. When updating from detox 5.10.0 to 6.0.4 I have a particular test that also gets stuck. When using --debug-synchronization I see detox info Sync Dispatch Queue: com.apple.main-thread too.

One thing I found was that my test was working if I removed the surrounding <Modal>. In the modal, even with all animations turned off it would not work.

@no-response no-response bot closed this as completed Mar 7, 2018
@no-response
Copy link

no-response bot commented Mar 7, 2018

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

@BenBach
Copy link

BenBach commented Mar 16, 2018

Did you guys find a solution for this?

@ericlewis
Copy link

As an FYI, if you are using Lottie, it will hang. Disabling animations on Lottie makes things work.

@LeoNatan
Copy link
Contributor

@ericlewis Do you mind opening a new issue for the Lottie situation and attaching a small sample project where this reproduces? Thanks

@BenBach
Copy link

BenBach commented Jun 30, 2018

@ericlewis we have the same problem :-( did you find a workaround? Would really help us

@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants