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

iOS: Hybrid app with native first screen never reports that it's ready #933

Closed
Ilushkanama opened this issue Sep 12, 2018 · 7 comments · Fixed by #964
Closed

iOS: Hybrid app with native first screen never reports that it's ready #933

Ilushkanama opened this issue Sep 12, 2018 · 7 comments · Fixed by #964

Comments

@Ilushkanama
Copy link

Description

This issue follows #615. The problem supposed to be resolved but we ran into it when we tried to use Detox to test a hybrid app.

Our app loads RN bundle on launch, but start screen has no RN content. If we log what grey_busyResourcesReturnEarly: calls result to, logs show that the function returns a set with single WXRNLoadIdlingResource element. Changing notification name in waitForReactNativeLoadWithCompletionHandler: from RCTContentDidAppearNotification to RCTJavaScriptDidLoadNotification resolves the issue.

Steps to Reproduce

You can reproduce this issue trying to test a hybrid app with native start screen. I can create test project if it's needed.

Detox, Node, Device, Xcode and macOS Versions

  • Detox: 8.2.3
  • React Native: 0.55.4
  • Node: 10.9.0
  • Device: iOS simulator - iPhone 7 (11.4)
  • Xcode: 9.4.1
  • macOS: 10.13.6

Device and verbose Detox logs

Detox logs contain following output:

detox[73523] TRACE: [DetoxServer.js/MESSAGE] role=tester action=isReady (sessionId=a3b40c1c-876b-2640-b85c-429f4c19373c)
detox[73523] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=a3b40c1c-876b-2640-b85c-429f4c19373c)
detox[73523] DEBUG: [DetoxServer.js/LOGIN] role=testee, sessionId=a3b40c1c-876b-2640-b85c-429f4c19373c
detox[73523] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=testee, sessionId=a3b40c1c-876b-2640-b85c-429f4c19373c
 FAIL  e2e/firstTest.spec.js (120.592s)
    ✕ should have offers for today (3ms)

  ●  › should have offers for today

    Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. 
@Ilushkanama Ilushkanama changed the title Hybrid app with native first screen never reports that it's ready. Hybrid app with native first screen never reports that it's ready Sep 12, 2018
@Ilushkanama Ilushkanama changed the title Hybrid app with native first screen never reports that it's ready iOS: Hybrid app with native first screen never reports that it's ready Sep 12, 2018
@LeoNatan
Copy link
Contributor

LeoNatan commented Sep 13, 2018

I’ll look at this when I get back from my vacation. Thanks

@LeoNatan
Copy link
Contributor

May I ask why you load the bundle on launch? Just want to understand the usecase.

@LeoNatan
Copy link
Contributor

@Ilushkanama 👆🏻

@cucumbur
Copy link

cucumbur commented Sep 27, 2018

The mobile app I am developing for is also structured this way - bundle load on launch / first screen, and it also runs into this problem. I am new to the codebase so I can't say exactly why we do things this way, although it might be pertinent that we use Haul for bundling rather than expo or metro. I am not an iOS developer, so I wasn't able to do targeted debugging (outside of the detox verbose logging) like Ilushkanama did, but at minimum I did attempt to fix the problem via the same method and it was insufficient to fix the problem, in this case. Adding a 'dummy' react view to the launch screen is my hacky fix
edit: Yes, sorry, I meant a workaround solely to be done on the individual project one is working on, rather than a a suggestion of an actual "fix", since the problem itself is an issue of unconventional usage and not the detox library. Just wanted to mention it in case someone else is dealing with that

@LeoNatan
Copy link
Contributor

That's is a workaround, not a fix.
I am trying to understand the usecase. Why are you spinning an RN bridge if you do not intent to use it yet?

@Ilushkanama
Copy link
Author

@LeoNatan we have onboarding as initial screen, which most of the users only see once. Right after the initial screen user is taken to the main screen, which contains RN things. RN bundle takes ~2 seconds to load. Basically, we have two scenarios for app launch:

  1. onboard new user then proceed to the main screen
  2. show main screen immediately if user was onboarded earlier

In the second case, it's obvious why we need to load RN bundle on launch - it's required by RN stuff on the main screen.
In the first case, postponing bundle loading until onboarding ends will result to users looking at empty screen for ~2 seconds after they complete onboarding. That's not the best UX. Loading RN bundle on app launch solves that problem.

@LeoNatan
Copy link
Contributor

Thanks

LeoNatan added a commit that referenced this issue Oct 2, 2018
…ation rather than RCTContentDidAppearNotification

Fixes #933
LeoNatan added a commit that referenced this issue Oct 9, 2018
…ntDidAppear (#964)

* Refine WXRNLoadIdlingResource to wait for RCTJavaScriptDidLoadNotification rather than RCTContentDidAppearNotification

Fixes #933

* Test

Signed-off-by: Leo Natan <[email protected]>

* Revert "Test"

This reverts commit a4f24ab.

Signed-off-by: Leo Natan <[email protected]>

* Update ReactNativeSupport.m
@lock lock bot locked as resolved and limited conversation to collaborators Oct 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants