mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-09 17:13:46 +08:00
Remove timeouts from react instance loading
Reviewed By: lexs Differential Revision: D2847813 fb-gh-sync-id: b4cb08633da8e637b0ec25a29bc21b963e337deb
This commit is contained in:
committed by
facebook-github-bot-7
parent
c2d75d7a65
commit
29238eb3eb
@@ -16,18 +16,17 @@ import java.io.StringWriter;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.facebook.common.logging.FLog;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.queue.CatalystQueueConfiguration;
|
||||
import com.facebook.react.bridge.queue.CatalystQueueConfigurationImpl;
|
||||
import com.facebook.react.bridge.queue.CatalystQueueConfigurationSpec;
|
||||
import com.facebook.react.bridge.queue.QueueThreadExceptionHandler;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import com.facebook.systrace.TraceListener;
|
||||
|
||||
@@ -41,9 +40,6 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||
@DoNotStrip
|
||||
public class CatalystInstanceImpl implements CatalystInstance {
|
||||
|
||||
private static final int BRIDGE_SETUP_TIMEOUT_MS = 30000;
|
||||
private static final int LOAD_JS_BUNDLE_TIMEOUT_MS = 30000;
|
||||
|
||||
private static final AtomicInteger sNextInstanceIdForTrace = new AtomicInteger(1);
|
||||
|
||||
// Access from any thread
|
||||
@@ -96,7 +92,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
||||
}
|
||||
}
|
||||
}).get(BRIDGE_SETUP_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
}).get();
|
||||
} catch (Exception t) {
|
||||
throw new RuntimeException("Failed to initialize bridge", t);
|
||||
}
|
||||
@@ -159,7 +155,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
|
||||
return true;
|
||||
}
|
||||
}).get(LOAD_JS_BUNDLE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
}).get();
|
||||
} catch (Exception t) {
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ public class SimpleSettableFuture<T> implements Future<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the eception. If another thread has called {@link #get}, they will immediately receive the
|
||||
* exception. set or setException must only be called once.
|
||||
* Sets the exception. If another thread has called {@link #get}, they will immediately receive
|
||||
* the exception. set or setException must only be called once.
|
||||
*/
|
||||
public void setException(Exception exception) {
|
||||
checkNotSet();
|
||||
@@ -61,10 +61,14 @@ public class SimpleSettableFuture<T> implements Future<T> {
|
||||
return mReadyLatch.getCount() == 0;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public T get() throws InterruptedException, ExecutionException {
|
||||
throw new UnsupportedOperationException("Must use a timeout");
|
||||
public @Nullable T get() throws InterruptedException, ExecutionException {
|
||||
mReadyLatch.await();
|
||||
if (mException != null) {
|
||||
throw new ExecutionException(mException);
|
||||
}
|
||||
|
||||
return mResult;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,12 +81,8 @@ public class SimpleSettableFuture<T> implements Future<T> {
|
||||
@Override
|
||||
public @Nullable T get(long timeout, TimeUnit unit) throws
|
||||
InterruptedException, ExecutionException, TimeoutException {
|
||||
try {
|
||||
if (!mReadyLatch.await(timeout, unit)) {
|
||||
throw new TimeoutException("Timed out waiting for result");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
if (!mReadyLatch.await(timeout, unit)) {
|
||||
throw new TimeoutException("Timed out waiting for result");
|
||||
}
|
||||
if (mException != null) {
|
||||
throw new ExecutionException(mException);
|
||||
|
||||
Reference in New Issue
Block a user