Skip to content

Commit

Permalink
Delete native UI template (#39487)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39487

changelog: [internal]

renderTemplateToSurface isn't used, let's remove it.

Reviewed By: javache

Differential Revision: D49313868

fbshipit-source-id: 9019d5b4adbd23632f27dd61bc18a97b447575d4
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Oct 6, 2023
1 parent d0f750e commit 1719a07
Show file tree
Hide file tree
Showing 21 changed files with 6 additions and 554 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1237,8 +1237,7 @@ private void attachRootViewToInstance(final ReactRoot reactRoot) {
reactRoot.getRootViewGroup(),
initialProperties == null
? new WritableNativeMap()
: Arguments.fromBundle(initialProperties),
reactRoot.getInitialUITemplate());
: Arguments.fromBundle(initialProperties));
reactRoot.setRootViewTag(rootTag);
reactRoot.runApplication();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public interface ReactRootViewEventListener {
private @Nullable ReactInstanceManager mReactInstanceManager;
private @Nullable String mJSModuleName;
private @Nullable Bundle mAppProperties;
private @Nullable String mInitialUITemplate;
private @Nullable CustomGlobalLayoutListener mCustomGlobalLayoutListener;
private @Nullable ReactRootViewEventListener mRootViewEventListener;
private int mRootViewTag =
Expand Down Expand Up @@ -452,14 +451,6 @@ public void startReactApplication(ReactInstanceManager reactInstanceManager, Str
startReactApplication(reactInstanceManager, moduleName, null);
}

/** {@see #startReactApplication(ReactInstanceManager, String, android.os.Bundle, String)} */
public void startReactApplication(
ReactInstanceManager reactInstanceManager,
String moduleName,
@Nullable Bundle initialProperties) {
startReactApplication(reactInstanceManager, moduleName, initialProperties, null);
}

/**
* Schedule rendering of the react component rendered by the JS application from the given JS
* module (@{param moduleName}) using provided {@param reactInstanceManager} to attach to the JS
Expand All @@ -470,8 +461,7 @@ public void startReactApplication(
public void startReactApplication(
ReactInstanceManager reactInstanceManager,
String moduleName,
@Nullable Bundle initialProperties,
@Nullable String initialUITemplate) {
@Nullable Bundle initialProperties) {
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "startReactApplication");
try {
UiThreadUtil.assertOnUiThread();
Expand All @@ -486,7 +476,6 @@ public void startReactApplication(
mReactInstanceManager = reactInstanceManager;
mJSModuleName = moduleName;
mAppProperties = initialProperties;
mInitialUITemplate = initialUITemplate;

mReactInstanceManager.createReactContextInBackground();
// if in this experiment, we initialize the root earlier in startReactApplication
Expand Down Expand Up @@ -651,11 +640,6 @@ public String getJSModuleName() {
return mAppProperties;
}

@Override
public @Nullable String getInitialUITemplate() {
return mInitialUITemplate;
}

@ThreadConfined(UI)
public void setAppProperties(@Nullable Bundle appProperties) {
UiThreadUtil.assertOnUiThread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public interface UIManager extends JSIModule, PerformanceCounter {
@UiThread
@ThreadConfined(UI)
@Deprecated
<T extends View> int addRootView(
final T rootView, WritableMap initialProps, @Nullable String initialUITemplate);
<T extends View> int addRootView(final T rootView, WritableMap initialProps);

/** Registers a new root view with width and height. */
@AnyThread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ public void startSurfaceWithConstraints(
boolean isRTL,
boolean doLeftAndRightSwapInRTL);

public void renderTemplateToSurface(int surfaceId, String uiTemplate);

public void stopSurface(int surfaceId);

public void setPixelDensity(float pointScaleFactor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ public native void startSurfaceWithConstraints(
boolean isRTL,
boolean doLeftAndRightSwapInRTL);

@Override
public native void renderTemplateToSurface(int surfaceId, String uiTemplate);

@Override
public native void stopSurface(int surfaceId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ public FabricUIManager(
@UiThread
@ThreadConfined(UI)
@Deprecated
public <T extends View> int addRootView(
final T rootView, final WritableMap initialProps, final @Nullable String initialUITemplate) {
public <T extends View> int addRootView(final T rootView, final WritableMap initialProps) {
ReactSoftExceptionLogger.logSoftException(
TAG,
new IllegalViewOperationException(
Expand All @@ -256,9 +255,6 @@ public <T extends View> int addRootView(
FLog.d(TAG, "Starting surface for module: %s and reactTag: %d", moduleName, rootTag);
}
mBinding.startSurface(rootTag, moduleName, (NativeMap) initialProps);
if (initialUITemplate != null) {
mBinding.renderTemplateToSurface(rootTag, initialUITemplate);
}
return rootTag;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public interface ReactRoot {
@Nullable
Bundle getAppProperties();

@Nullable
String getInitialUITemplate();

String getJSModuleName();

/** Fabric or Default UI Manager, see {@link UIManagerType} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public Map<String, Long> getPerformanceCounters() {
}

public <T extends View> int addRootView(final T rootView) {
return addRootView(rootView, null, null);
return addRootView(rootView, null);
}

/**
Expand Down Expand Up @@ -341,8 +341,7 @@ public void synchronouslyUpdateViewOnUIThread(int tag, ReadableMap props) {
* <p>TODO(6242243): Make addRootView thread safe NB: this method is horribly not-thread-safe.
*/
@Override
public <T extends View> int addRootView(
final T rootView, WritableMap initialProps, @Nullable String initialUITemplate) {
public <T extends View> int addRootView(final T rootView, WritableMap initialProps) {
Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "UIManagerModule.addRootView");
final int tag = ReactRootViewTagGenerator.getNextRootViewTag();
final ReactApplicationContext reactApplicationContext = getReactApplicationContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ add_react_common_subdir(react/renderer/componentregistry)
add_react_common_subdir(react/renderer/mounting)
add_react_common_subdir(react/renderer/scheduler)
add_react_common_subdir(react/renderer/telemetry)
add_react_common_subdir(react/renderer/templateprocessor)
add_react_common_subdir(react/renderer/uimanager)
add_react_common_subdir(react/renderer/core)
add_react_common_subdir(react/renderer/element)
Expand Down Expand Up @@ -164,7 +163,6 @@ add_executable(reactnative_unittest
${REACT_COMMON_DIR}/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp
${REACT_COMMON_DIR}/react/renderer/runtimescheduler/tests/SchedulerPriorityTest.cpp
${REACT_COMMON_DIR}/react/renderer/telemetry/tests/TransactionTelemetryTest.cpp
${REACT_COMMON_DIR}/react/renderer/templateprocessor/tests/UITemplateProcessorTest.cpp
${REACT_COMMON_DIR}/react/renderer/textlayoutmanager/tests/TextLayoutManagerTest.cpp
${REACT_COMMON_DIR}/react/renderer/uimanager/tests/FabricUIManagerTest.cpp

Expand Down Expand Up @@ -209,7 +207,6 @@ add_executable(reactnative_unittest
react_render_graphics
react_render_mapbuffer
react_render_mounting
react_render_templateprocessor
react_render_textlayoutmanager
react_render_uimanager
react_utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,6 @@ void Binding::startSurfaceWithConstraints(
mountingManager->onSurfaceStart(surfaceId);
}

void Binding::renderTemplateToSurface(jint surfaceId, jstring uiTemplate) {
SystraceSection s("FabricUIManagerBinding::renderTemplateToSurface");

auto scheduler = getScheduler();
if (!scheduler) {
LOG(ERROR) << "Binding::renderTemplateToSurface: scheduler disappeared";
return;
}

auto env = jni::Environment::current();
const char* nativeString = env->GetStringUTFChars(uiTemplate, JNI_FALSE);
scheduler->renderTemplateToSurface(surfaceId, nativeString);
env->ReleaseStringUTFChars(uiTemplate, nativeString);
}

void Binding::stopSurface(jint surfaceId) {
SystraceSection s("FabricUIManagerBinding::stopSurface");

Expand Down Expand Up @@ -581,8 +566,6 @@ void Binding::registerNatives() {
"getInspectorDataForInstance", Binding::getInspectorDataForInstance),
makeNativeMethod(
"startSurfaceWithConstraints", Binding::startSurfaceWithConstraints),
makeNativeMethod(
"renderTemplateToSurface", Binding::renderTemplateToSurface),
makeNativeMethod("stopSurface", Binding::stopSurface),
makeNativeMethod("setConstraints", Binding::setConstraints),
makeNativeMethod("setPixelDensity", Binding::setPixelDensity),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ class Binding : public jni::HybridClass<Binding>,
jboolean isRTL,
jboolean doLeftAndRightSwapInRTL);

void renderTemplateToSurface(jint surfaceId, jstring uiTemplate);

void stopSurface(jint surfaceId);

void registerSurface(SurfaceHandlerBinding* surfaceHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ target_link_libraries(
react_render_runtimescheduler
react_render_scheduler
react_render_telemetry
react_render_templateprocessor
react_render_textlayoutmanager
react_render_uimanager
react_utils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,33 +121,6 @@ bool ComponentDescriptorRegistry::hasComponentDescriptorAt(
return iterator != _registryByHandle.end();
}

ShadowNode::Shared ComponentDescriptorRegistry::createNode(
Tag tag,
const std::string& viewName,
SurfaceId surfaceId,
const folly::dynamic& propsDynamic,
const InstanceHandle::Shared& instanceHandle) const {
auto unifiedComponentName = componentNameByReactViewName(viewName);
const auto& componentDescriptor = this->at(unifiedComponentName);

const auto fragment =
ShadowNodeFamilyFragment{tag, surfaceId, instanceHandle};
auto family = componentDescriptor.createFamily(fragment);
const auto props = componentDescriptor.cloneProps(
PropsParserContext{surfaceId, *contextContainer_.get()},
nullptr,
RawProps(propsDynamic));
const auto state = componentDescriptor.createInitialState(props, family);

return componentDescriptor.createShadowNode(
{
/* .props = */ props,
/* .children = */ ShadowNodeFragment::childrenPlaceholder(),
/* .state = */ state,
},
family);
}

void ComponentDescriptorRegistry::setFallbackComponentDescriptor(
const SharedComponentDescriptor& descriptor) {
_fallbackComponentDescriptor = descriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ class ComponentDescriptorRegistry {

bool hasComponentDescriptorAt(ComponentHandle componentHandle) const;

ShadowNode::Shared createNode(
Tag tag,
const std::string& viewName,
SurfaceId surfaceId,
const folly::dynamic& props,
const InstanceHandle::Shared& instanceHandle) const;

void setFallbackComponentDescriptor(
const SharedComponentDescriptor& descriptor);
ComponentDescriptor::Shared getFallbackComponentDescriptor() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ target_link_libraries(react_render_scheduler
react_render_graphics
react_render_mounting
react_render_runtimescheduler
react_render_templateprocessor
react_render_uimanager
react_utils
rrc_root
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <react/renderer/mounting/MountingOverrideDelegate.h>
#include <react/renderer/mounting/ShadowViewMutation.h>
#include <react/renderer/runtimescheduler/RuntimeScheduler.h>
#include <react/renderer/templateprocessor/UITemplateProcessor.h>
#include <react/renderer/uimanager/UIManager.h>
#include <react/renderer/uimanager/UIManagerBinding.h>

Expand Down Expand Up @@ -256,44 +255,6 @@ void Scheduler::unregisterSurface(
surfaceHandler.setUIManager(nullptr);
}

void Scheduler::renderTemplateToSurface(
SurfaceId surfaceId,
const std::string& uiTemplate) {
SystraceSection s("Scheduler::renderTemplateToSurface");
try {
if (uiTemplate.empty()) {
return;
}
NativeModuleRegistry nMR;
auto tree = UITemplateProcessor::buildShadowTree(
uiTemplate,
surfaceId,
folly::dynamic::object(),
*componentDescriptorRegistry_,
nMR,
reactNativeConfig_);

uiManager_->getShadowTreeRegistry().visit(
surfaceId, [=](const ShadowTree& shadowTree) {
return shadowTree.tryCommit(
[&](RootShadowNode const& oldRootShadowNode) {
return std::make_shared<RootShadowNode>(
oldRootShadowNode,
ShadowNodeFragment{
/* .props = */ ShadowNodeFragment::propsPlaceholder(),
/* .children = */
std::make_shared<ShadowNode::ListOfShared>(
ShadowNode::ListOfShared{tree}),
});
},
{/* default commit options */});
});
} catch (const std::exception& e) {
LOG(ERROR) << " >>>> EXCEPTION <<< rendering uiTemplate in "
<< "Scheduler::renderTemplateToSurface: " << e.what();
}
}

const ComponentDescriptor*
Scheduler::findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN(
ComponentHandle handle) const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ class Scheduler final : public UIManagerDelegate {
InspectorData getInspectorDataForInstance(
const EventEmitter& eventEmitter) const noexcept;

void renderTemplateToSurface(
SurfaceId surfaceId,
const std::string& uiTemplate);

/*
* This is broken. Please do not use.
* `ComponentDescriptor`s are not designed to be used outside of `UIManager`,
Expand Down

This file was deleted.

Loading

0 comments on commit 1719a07

Please sign in to comment.