Skip to content

Conversation

shonsirsha
Copy link
Collaborator

@shonsirsha shonsirsha commented Aug 18, 2025

Fixing it by adding a check in WebView.swift for a message
sent from the react app signaling react app is ready.

On ready, it reveals the webview smoothly with transition.

@shonsirsha shonsirsha requested a review from benma August 18, 2025 08:29
@shonsirsha shonsirsha changed the title ios: fix app flickers on start by ios: fix app flickers on start Aug 18, 2025
@shonsirsha shonsirsha force-pushed the ios-add-launch-screen branch 2 times, most recently from a756c26 to 57f7676 Compare August 19, 2025 05:58
@shonsirsha shonsirsha force-pushed the ios-add-launch-screen branch from 57f7676 to 6173c48 Compare August 19, 2025 11:59
@shonsirsha shonsirsha requested a review from benma August 19, 2025 12:01
@shonsirsha shonsirsha force-pushed the ios-add-launch-screen branch from 6173c48 to a97dd49 Compare August 19, 2025 12:07
@shonsirsha
Copy link
Collaborator Author

PTAL @benma

@shonsirsha shonsirsha force-pushed the ios-add-launch-screen branch 3 times, most recently from 3640f24 to f5f9bb5 Compare August 20, 2025 03:17
checkReactAppReady(webView: webView)
}

private func checkReactAppReady(webView: WKWebView, retryCount: Int = 0) {
Copy link
Collaborator Author

@shonsirsha shonsirsha Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using an arbitrary-valued delay, here we're checking for reactAppReady property instead. Check runs recursively until that value is set to true (with max retry).

This property is set by the useAppReady hook from the react app. cc @benma

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Instead of polling, please call directly into Swift. See this as an example where TS is calling goCall(), and the call is handled in Swift:

contentController.add(bridge, name: "goCall")

This would be better as it requires fewer calls and has an even smaller delay until ready. When the react app is ready, tell Swift to transition.

Copy link
Contributor

@benma benma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(see comment)

@shonsirsha shonsirsha force-pushed the ios-add-launch-screen branch from f5f9bb5 to 4d188c7 Compare August 25, 2025 11:41
@shonsirsha
Copy link
Collaborator Author

@benma , PTAL thanks a lot for the review!

@shonsirsha shonsirsha force-pushed the ios-add-launch-screen branch 3 times, most recently from 71464f8 to 9cd288d Compare August 25, 2025 11:59
* until the React app has finished loading its initial data.
*/
export const useAppReady = (accounts?: IAccount[], devices?: TDevices) => {
useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add a fallback?

useEffect(() => {
     const timer = setTimeout(() => {
        /* send appReady */ 
     }, 3000); 
     return () => clearTimeout(timer);

Just in case there is some weird delay in getting accounts and devices results.

Otherwise code looks good, I'll test it on a device tomorrow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay - added the fallback to call regardless of the devices || accounts results.

@shonsirsha shonsirsha force-pushed the ios-add-launch-screen branch from 9cd288d to 49040ea Compare August 26, 2025 06:27
@shonsirsha
Copy link
Collaborator Author

@benma thanks 👍 PTAL (also rebased).

@shonsirsha shonsirsha force-pushed the ios-add-launch-screen branch from 49040ea to c7fd4e5 Compare August 27, 2025 08:37
Copy link
Contributor

@benma benma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately it does not work for me, WebView.swift never gets the appReady message and the webview stays invisible.

@shonsirsha
Copy link
Collaborator Author

Unfortunately it does not work for me, WebView.swift never gets the appReady message and the webview stays invisible.

I think it may be the postMessage()- I made an update which was wrong.

@shonsirsha shonsirsha force-pushed the ios-add-launch-screen branch from c7fd4e5 to 145d212 Compare September 1, 2025 11:29
Fixing it by adding a check in WebView.swift for  a message
sent from the react app signaling react app is ready.

On ready, it reveals the webview smoothly with transition.
@shonsirsha shonsirsha force-pushed the ios-add-launch-screen branch from 145d212 to 3fe986e Compare September 1, 2025 11:31
@shonsirsha
Copy link
Collaborator Author

@benma , thanks for the review. Fixed the bug and simplified the hooks. PTAL 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants