Skip to content

Commit

Permalink
Make sure that a valid GL context is available before generating Disp…
Browse files Browse the repository at this point in the history
…layLists

Summary: There were cases in which we were trying to create DisplayLists before a valid Context was available. This fixes it by checking that the Activity's DecorView has been drawn at least once.

Reviewed By: emilsjolander, IanChilds, muraziz

Differential Revision: D4914956

fbshipit-source-id: 2421f658c1ad2a45bc7b68e67a154804c35fe263
  • Loading branch information
pasqualeanatriello authored and facebook-github-bot committed Apr 19, 2017
1 parent a0e503c commit 1bcbe24
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions litho-core/src/main/java/com/facebook/litho/LayoutState.java
Expand Up @@ -30,6 +30,7 @@
import android.support.v4.view.accessibility.AccessibilityManagerCompat;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.view.accessibility.AccessibilityManager;

import com.facebook.litho.animation.AnimationBinding;
Expand Down Expand Up @@ -1010,6 +1011,18 @@ private static void collectDisplayLists(LayoutState layoutState) {
return;
}

// If we have no window or the hierarchy has never been drawn before we cannot guarantee that
// a valid GL context exists. In this case just bail.
final Window window = activity.getWindow();
if (window == null) {
return;
}

final View decorView = window.getDecorView();
if (decorView == null || decorView.getDrawingTime() == 0) {
return;
}

for (int i = 0, count = layoutState.getMountableOutputCount(); i < count; i++) {
final LayoutOutput output = layoutState.getMountableOutputAt(i);
final Component component = output.getComponent();
Expand Down

0 comments on commit 1bcbe24

Please sign in to comment.