Skip to content

Commit

Permalink
Ensure that ReactInstanceManager is still alive when animation system…
Browse files Browse the repository at this point in the history
… updates views in Fabric

Summary:
This diff ensures that ReactInstanceManager has a valid catalystInstance when updating views as part of the animation system.
This also force the update of views to be posted in the UI Thread

Changelog: [internal]

Reviewed By: JoshuaGross

Differential Revision: D18311782

fbshipit-source-id: 1f1e7b0d34346f34b3607e5b75e5c14cda3f4861
  • Loading branch information
mdvacca authored and facebook-github-bot committed Nov 5, 2019
1 parent c6b16ec commit 3281714
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ public void createView(int tag, String className, int rootViewTag, ReadableMap p
}

@ReactMethod
public void updateView(int tag, String className, ReadableMap props) {
public void updateView(final int tag, final String className, final ReadableMap props) {
if (DEBUG) {
String message =
"(UIManager.updateView) tag: " + tag + ", class: " + className + ", props: " + props;
Expand All @@ -478,10 +478,19 @@ public void updateView(int tag, String className, ReadableMap props) {
}
int uiManagerType = ViewUtil.getUIManagerType(tag);
if (uiManagerType == FABRIC) {
UIManager fabricUIManager =
UIManagerHelper.getUIManager(getReactApplicationContext(), uiManagerType);
if (fabricUIManager != null) {
fabricUIManager.synchronouslyUpdateViewOnUIThread(tag, props);
ReactApplicationContext reactApplicationContext = getReactApplicationContext();
if (reactApplicationContext.hasActiveCatalystInstance()) {
final UIManager fabricUIManager =
UIManagerHelper.getUIManager(reactApplicationContext, uiManagerType);
if (fabricUIManager != null) {
reactApplicationContext.runOnUiQueueThread(
new Runnable() {
@Override
public void run() {
fabricUIManager.synchronouslyUpdateViewOnUIThread(tag, props);
}
});
}
}
} else {
mUIImplementation.updateView(tag, className, props);
Expand Down

0 comments on commit 3281714

Please sign in to comment.