use synchronous fragment transaction with embed frame #133
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
relates to #132
This update changes the
AppcuesWrapperView
implementation to usecommitNow()
(synchronous) instead ofcommit()
(asynchronous) - to avoid an observed timing issue where a crash like the following could occur:I believe the observed issue was due to the asynchronous nature of
commit()
, and some scenarios where the React Native view hierarchy is rapidly updating at the same time anAppcuesFrameView
is attempting to be created in the layout. One observed scenario was a launch from push notification.I was able to reproduce this using a test case that would cold launch the app from a deep link, and try to add an
AppcuesFrameView
in the layout before immediately (next line) navigating away to a new page. In the SignInScreen.js in the sample app here, I used some test code like below to accomplish this.Then, later in the view, had a conditionally added
AppcuesFrameView
that would attempt to initialize right as the view was being torn down and navigated away.when the native implementation uses
commitNow()
instead, the transaction runs synchronously on the UI thread, as expected, and there is no crash in this scenario.The other small change in
AppcuesReactNativeModule
is to simply remove the check for the current Activity at SDK init. It is not required to have an Activity at this moment, and quite possible in scenarios like Android push notification launch, that the Application is being started but the Activity has not yet started - it is still ok to initialize the Appcues SDK at that point.