Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android: attempt to fix assertion errors in ReactInstanceManager #4160

Merged
merged 1 commit into from
Aug 16, 2019
Merged
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 @@ -111,8 +111,7 @@ public BaseReactView(@NonNull Context context) {

setBackgroundColor(BACKGROUND_COLOR);

ReactInstanceManagerHolder.initReactInstanceManager(
((Activity) context).getApplication());
ReactInstanceManagerHolder.initReactInstanceManager((Activity)context);

// Hook this BaseReactView into ExternalAPI.
externalAPIScope = UUID.randomUUID().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.calendarevents.CalendarEventsPackage;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.core.PermissionListener;

/**
Expand Down Expand Up @@ -117,7 +118,13 @@ public static void onHostPause(Activity activity) {
= ReactInstanceManagerHolder.getReactInstanceManager();

if (reactInstanceManager != null) {
reactInstanceManager.onHostPause(activity);
// Try to avoid a crash because some devices trip on this assert:
// https://github.com/facebook/react-native/blob/df4e67fe75d781d1eb264128cadf079989542755/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java#L512
// Why this happens is a mystery wrapped in an enigma.
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (activity == reactContext.getCurrentActivity()) {
reactInstanceManager.onHostPause(activity);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.jitsi.meet.sdk;

import android.app.Activity;
import android.app.Application;
import android.support.annotation.Nullable;

import com.facebook.react.ReactInstanceManager;
Expand Down Expand Up @@ -175,9 +174,9 @@ static ReactInstanceManager getReactInstanceManager() {
* time. All {@code ReactRootView} instances will be tied to the one and
* only {@code ReactInstanceManager}.
*
* @param application {@code Application} instance which is running.
* @param activity {@code Activity} current running Activity.
*/
static void initReactInstanceManager(Application application) {
static void initReactInstanceManager(Activity activity) {
if (reactInstanceManager != null) {
return;
}
Expand Down Expand Up @@ -215,7 +214,8 @@ public List<ViewManager> createViewManagers(ReactApplicationContext reactContext

reactInstanceManager
= ReactInstanceManager.builder()
.setApplication(application)
.setApplication(activity.getApplication())
.setCurrentActivity(activity)
.setBundleAssetName("index.android.bundle")
.setJSMainModulePath("index.android")
.addPackages(packages)
Expand Down