Update KDocs for ReactHost.destroy() methods (#47536)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47536

I'm updating KDoc for ReactHost.destroy() methods to warn about potential deadlock when waiting for completion

changelog: [Android][Changed] update documentation for ReactHost.destroy() APIs

Reviewed By: shwanton

Differential Revision: D65734396

fbshipit-source-id: b7924cafce2fd58e2633736f922d303c61f6ad14
This commit is contained in:
David Vacca 2024-11-11 07:03:00 -08:00 committed by Facebook GitHub Bot
parent 685facfd53
commit 443bc32dc4
2 changed files with 35 additions and 2 deletions

View File

@ -111,7 +111,13 @@ public interface ReactHost {
* Entrypoint to destroy the ReactInstance. If the ReactInstance is reloading, will wait until
* reload is finished, before destroying.
*
* @param reason describing why ReactHost is being destroyed (e.g. memmory pressure)
* The destroy operation is asynchronous and the task returned by this method will complete when
* React Native gets destroyed. Note that the destroy operation will execute in multiple threads,
* in particular some of the sub-tasks will run in the UIThread. Calling
* [TaskInterface.waitForCompletion] from the UIThread will lead into a deadlock. Use [destroy]
* passing the onDestroyFinished callback to be notified when React Native gets destroyed.
*
* @param reason describing why ReactHost is being destroyed (e.g. memory pressure)
* @param ex exception that caused the trigger to destroy ReactHost (or null) This exception will
* be used to log properly the cause of destroy operation.
* @return A task that completes when React Native gets destroyed.
@ -125,7 +131,13 @@ public interface ReactHost {
* Entrypoint to destroy the ReactInstance. If the ReactInstance is reloading, will wait until
* reload is finished, before destroying.
*
* @param reason describing why ReactHost is being destroyed (e.g. memmory pressure)
* The destroy operation is asynchronous and the task returned by this method will complete when
* React Native gets destroyed. Note that the destroy operation will execute in multiple threads,
* in particular some of the sub-tasks will run in the UIThread. Calling
* [TaskInterface.waitForCompletion] from the UIThread will lead into a deadlock. Use
* onDestroyFinished callback to be notified when React Native gets destroyed.
*
* @param reason describing why ReactHost is being destroyed (e.g. memory pressure)
* @param ex exception that caused the trigger to destroy ReactHost (or null) This exception will
* be used to log properly the cause of destroy operation.
* @param onDestroyFinished callback that will be called when React Native gets destroyed.

View File

@ -543,6 +543,22 @@ public class ReactHostImpl implements ReactHost {
InspectorNetworkHelper.loadNetworkResource(url, listener);
}
/**
* Entrypoint to destroy the ReactInstance. If the ReactInstance is reloading, will wait until
* reload is finished, before destroying.
*
* <p>The destroy operation is asynchronous and the task returned by this method will complete
* when React Native gets destroyed. Note that the destroy operation will execute in multiple
* threads, in particular some of the sub-tasks will run in the UIThread. Calling {@link
* TaskInterface#waitForCompletion()} from the UIThread will lead into a deadlock. Use
* onDestroyFinished callback to be notified when React Native gets destroyed.
*
* @param reason describing why ReactHost is being destroyed (e.g. memory pressure)
* @param ex exception that caused the trigger to destroy ReactHost (or null) This exception will
* be used to log properly the cause of destroy operation.
* @param onDestroyFinished callback that will be called when React Native gets destroyed.
* @return A task that completes when React Native gets destroyed.
*/
@NonNull
@Override
public TaskInterface<Void> destroy(
@ -566,6 +582,11 @@ public class ReactHostImpl implements ReactHost {
* Entrypoint to destroy the ReactInstance. If the ReactInstance is reloading, will wait until
* reload is finished, before destroying.
*
* <p>The destroy operation is asynchronous and the task returned by this method will complete
* when React Native gets destroyed. Note that the destroy operation will execute in multiple
* threads, in particular some of the sub-tasks will run in the UIThread. Calling {@link
* TaskInterface#waitForCompletion()} from the UIThread will lead into a deadlock.
*
* @param reason {@link String} describing why ReactHost is being destroyed (e.g. memory pressure)
* @param ex {@link Exception} exception that caused the trigger to destroy ReactHost (or null)
* This exception will be used to log properly the cause of destroy operation.