Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.modules.core.ReactChoreographer;
import com.facebook.react.modules.debug.interfaces.DeveloperSettings;
import com.facebook.react.packagerconnection.RequestHandler;
import com.facebook.react.uimanager.DisplayMetricsHolder;
import com.facebook.react.uimanager.ReactRoot;
Expand Down Expand Up @@ -194,7 +193,7 @@ public interface ReactInstanceEventListener
private boolean mUseFallbackBundle = true;
private volatile boolean mInstanceManagerInvalidated = false;

private class ReactContextInitParams {
private static class ReactContextInitParams {
private final JavaScriptExecutorFactory mJsExecutorFactory;
private final JSBundleLoader mJsBundleLoader;

Expand Down Expand Up @@ -301,14 +300,11 @@ public static ReactInstanceManagerBuilder builder() {
mDevSupportManager.startInspector();
}

// Using `if (true)` just to prevent tests / lint errors.
if (true) {
// Legacy architecture of React Native is deprecated and can't be initialized anymore.
// More details on:
// https://github.com/react-native-community/discussions-and-proposals/blob/nc/legacy-arch-removal/proposals/0929-legacy-architecture-removal.md
throw new UnsupportedOperationException(
"ReactInstanceManager.createReactContext is unsupported.");
}
// Legacy architecture of React Native is deprecated and can't be initialized anymore.
// More details on:
// https://github.com/react-native-community/discussions-and-proposals/blob/nc/legacy-arch-removal/proposals/0929-legacy-architecture-removal.md
throw new UnsupportedOperationException(
"ReactInstanceManager.createReactContext is unsupported.");
}

private ReactInstanceDevHelper createDevHelperInterface() {
Expand Down Expand Up @@ -450,7 +446,6 @@ private void recreateReactContextInBackgroundInner() {
UiThreadUtil.assertOnUiThread();

if (mUseDeveloperSupport && mJSMainModulePath != null) {
final DeveloperSettings devSettings = mDevSupportManager.getDevSettings();
if (!Systrace.isTracing(TRACE_TAG_REACT)) {
if (mBundleLoader == null) {
mDevSupportManager.handleReloadJS();
Expand Down Expand Up @@ -1164,6 +1159,7 @@ private void runCreateReactContextOnNewThread(final ReactContextInitParams initP
try {
ReactInstanceManager.this.mHasStartedDestroying.wait();
} catch (InterruptedException e) {
// Interrupted while waiting for destruction to complete, just retry
continue;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,13 @@ public class ReactInstanceManagerBuilder {
}

private companion object {
private val TAG: String = ReactInstanceManagerBuilder::class.java.simpleName

init {
LegacyArchitectureLogger.assertLegacyArchitecture(
"ReactInstanceManagerBuilder",
LegacyArchitectureLogLevel.ERROR,
)
}

private val TAG: String = ReactInstanceManagerBuilder::class.java.simpleName
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ public String getSurfaceID() {
return appProperties != null ? appProperties.getString("surfaceID") : null;
}

@Override
public AtomicInteger getState() {
return mState;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ internal abstract class AnimationDriver {
* start animating with the new properties (different destination or spring settings)
*/
open fun resetConfig(config: ReadableMap) {
throw JSApplicationCausedNativeException(
"Animation config for ${javaClass.simpleName} cannot be reset"
)
throw JSApplicationCausedNativeException("Animation config for AnimationDriver cannot be reset")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public void destroy() {
if (mFabricUIManager != null) {
mFabricUIManager.invalidate();
}
boolean wasIdle = (mPendingJSCalls.getAndSet(0) == 0);
mPendingJSCalls.getAndSet(0);

getReactQueueConfiguration()
.getJSQueueThread()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ internal class JavaMethodWrapper(
private var arguments: Array<Any?>? = null
private var jsArgumentsNeeded = 0

val signature: String?
get() {
if (!argumentsProcessed) {
processArguments()
}
return checkNotNull(internalSignature)
}

init {
method.isAccessible = true
parameterTypes = method.parameterTypes
Expand Down Expand Up @@ -86,14 +94,6 @@ internal class JavaMethodWrapper(
}
}

val signature: String?
get() {
if (!argumentsProcessed) {
processArguments()
}
return checkNotNull(internalSignature)
}

private fun buildSignature(method: Method, paramTypes: Array<Class<*>>, isSync: Boolean): String =
buildString(paramTypes.size + 2) {
if (isSync) {
Expand Down Expand Up @@ -249,13 +249,6 @@ internal class JavaMethodWrapper(
}

companion object {
init {
LegacyArchitectureLogger.assertLegacyArchitecture(
"JavaMethodWrapper",
LegacyArchitectureLogLevel.ERROR,
)
}

private val ARGUMENT_EXTRACTOR_BOOLEAN: ArgumentExtractor<Boolean> =
object : ArgumentExtractor<Boolean>() {
@Suppress("DEPRECATION")
Expand Down Expand Up @@ -388,6 +381,13 @@ internal class JavaMethodWrapper(
private val DEBUG =
PrinterHolder.printer.shouldDisplayLogMessage(ReactDebugOverlayTags.BRIDGE_CALLS)

init {
LegacyArchitectureLogger.assertLegacyArchitecture(
"JavaMethodWrapper",
LegacyArchitectureLogLevel.ERROR,
)
}

private fun paramTypeToChar(paramClass: Class<*>): Char {
val tryCommon = commonTypeToChar(paramClass)
if (tryCommon != '\u0000') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,15 @@ public class JavaOnlyMap() : ReadableMap, WritableMap {
override fun toString(): String = backingMap.toString()

override fun equals(other: Any?): Boolean {
return if (this === other) {
true
} else if (other == null || javaClass != other.javaClass) {
false
} else {
backingMap == (other as JavaOnlyMap).backingMap
if (this === other) {
return true
}
if (other !is JavaOnlyMap) {
return false
}
val thisBackingMap = backingMap
val otherBackingMap = other.backingMap
return thisBackingMap == otherBackingMap
}

override fun hashCode(): Int = backingMap.hashCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ private constructor(
override var count: Int = 0
private set

// returns the relative offset of the first byte of dynamic data
private val offsetForDynamicData: Int
get() = getKeyOffsetForBucketIndex(count)

init {
readHeader()
}
Expand All @@ -56,10 +60,6 @@ private constructor(
count = readUnsignedShort(buffer.position()).toInt()
}

// returns the relative offset of the first byte of dynamic data
private val offsetForDynamicData: Int
get() = getKeyOffsetForBucketIndex(count)

/**
* @param intKey Key to search for
* @return the "bucket index" for a key or -1 if not found. It uses a binary search algorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,43 +71,45 @@ public object DefaultReactHost {
exceptionHandler: (Exception) -> Unit = { throw it },
bindingsInstaller: BindingsInstaller? = null,
): ReactHost {
if (reactHost == null) {
reactHost?.let {
return it
}

val bundleLoader =
if (jsBundleFilePath != null) {
if (jsBundleFilePath.startsWith("assets://")) {
JSBundleLoader.createAssetLoader(context, jsBundleFilePath, true)
} else {
JSBundleLoader.createFileLoader(jsBundleFilePath)
}
val bundleLoader =
if (jsBundleFilePath != null) {
if (jsBundleFilePath.startsWith("assets://")) {
JSBundleLoader.createAssetLoader(context, jsBundleFilePath, true)
} else {
JSBundleLoader.createAssetLoader(context, "assets://$jsBundleAssetPath", true)
JSBundleLoader.createFileLoader(jsBundleFilePath)
}
val defaultTmmDelegateBuilder = DefaultTurboModuleManagerDelegate.Builder()
cxxReactPackageProviders.forEach { defaultTmmDelegateBuilder.addCxxReactPackage(it) }
val defaultReactHostDelegate =
DefaultReactHostDelegate(
jsMainModulePath = jsMainModulePath,
jsBundleLoader = bundleLoader,
reactPackages = packageList,
jsRuntimeFactory = jsRuntimeFactory ?: HermesInstance(),
bindingsInstaller = bindingsInstaller,
turboModuleManagerDelegateBuilder = defaultTmmDelegateBuilder,
exceptionHandler = exceptionHandler,
)
val componentFactory = ComponentFactory()
DefaultComponentsRegistry.register(componentFactory)
// TODO: T164788699 find alternative of accessing ReactHostImpl for initialising reactHost
reactHost =
ReactHostImpl(
context,
defaultReactHostDelegate,
componentFactory,
true /* allowPackagerServerAccess */,
useDevSupport,
)
}
return reactHost as ReactHost
} else {
JSBundleLoader.createAssetLoader(context, "assets://$jsBundleAssetPath", true)
}
val defaultTmmDelegateBuilder = DefaultTurboModuleManagerDelegate.Builder()
cxxReactPackageProviders.forEach { defaultTmmDelegateBuilder.addCxxReactPackage(it) }
val defaultReactHostDelegate =
DefaultReactHostDelegate(
jsMainModulePath = jsMainModulePath,
jsBundleLoader = bundleLoader,
reactPackages = packageList,
jsRuntimeFactory = jsRuntimeFactory ?: HermesInstance(),
bindingsInstaller = bindingsInstaller,
turboModuleManagerDelegateBuilder = defaultTmmDelegateBuilder,
exceptionHandler = exceptionHandler,
)
val componentFactory = ComponentFactory()
DefaultComponentsRegistry.register(componentFactory)
// TODO: T164788699 find alternative of accessing ReactHostImpl for initialising reactHost
val newReactHost =
ReactHostImpl(
context,
defaultReactHostDelegate,
componentFactory,
true /* allowPackagerServerAccess */,
useDevSupport,
)
reactHost = newReactHost
return newReactHost
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ package com.facebook.react.fabric.events

import android.annotation.SuppressLint
import com.facebook.jni.HybridClassBase
import com.facebook.proguard.annotations.DoNotStrip
import com.facebook.proguard.annotations.DoNotStripAny
import com.facebook.react.fabric.FabricSoLoader
import com.facebook.react.uimanager.events.BatchEventDispatchedListener

/**
* Class that acts as a proxy between the list of EventBeats registered in C++ and the Android side.
*/
@DoNotStrip
@DoNotStripAny
@SuppressLint("MissingNativeLoadLibrary")
internal class EventBeatManager : HybridClassBase(), BatchEventDispatchedListener {
init {
Expand Down
Loading