Program: 191634
Project: 191634
Buggy source:
/** 
 * Reloads the stack views upon launching Recents.
 */
private void reloadStackView(){
  RecentsTaskLoader loader=Recents.getTaskLoader();
  RecentsTaskLoadPlan loadPlan=RecentsImpl.consumeInstanceLoadPlan();
  if (loadPlan == null) {
    loadPlan=loader.createLoadPlan(this);
  }
  RecentsConfiguration config=Recents.getConfiguration();
  RecentsActivityLaunchState launchState=config.getLaunchState();
  if (!loadPlan.hasTasks()) {
    loader.preloadTasks(loadPlan,launchState.launchedToTaskId,launchState.launchedFromHome);
  }
  RecentsTaskLoadPlan.Options loadOpts=new RecentsTaskLoadPlan.Options();
  loadOpts.runningTaskId=launchState.launchedToTaskId;
  loadOpts.numVisibleTasks=launchState.launchedNumVisibleTasks;
  loadOpts.numVisibleTaskThumbnails=launchState.launchedNumVisibleThumbnails;
  loader.loadTasks(this,loadPlan,loadOpts);
  TaskStack stack=loadPlan.getTaskStack();
  mRecentsView.onReload(mIsVisible,stack.getTaskCount() == 0);
  mRecentsView.updateStack(stack,true);
  boolean animateNavBarScrim=!launchState.launchedViaDockGesture;
  mScrimViews.updateNavBarScrim(animateNavBarScrim,stack.getTaskCount() > 0,null);
  boolean wasLaunchedByAm=!launchState.launchedFromHome && !launchState.launchedFromApp;
  if (wasLaunchedByAm) {
    EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
  }
  if (launchState.launchedWithAltTab) {
    MetricsLogger.count(this,"String_Node_Str",1);
  }
 else {
    MetricsLogger.count(this,"String_Node_Str",1);
  }
  if (launchState.launchedFromApp) {
    Task launchTarget=stack.getLaunchTarget();
    int launchTaskIndexInStack=launchTarget != null ? stack.indexOfStackTask(launchTarget) : 0;
    MetricsLogger.count(this,"String_Node_Str",1);
    MetricsLogger.histogram(this,"String_Node_Str",launchTaskIndexInStack);
  }
 else {
    MetricsLogger.count(this,"String_Node_Str",1);
  }
  int taskCount=mRecentsView.getStack().getTaskCount();
  MetricsLogger.histogram(this,"String_Node_Str",taskCount);
  mIsVisible=true;
}

Fixed version (ground truth):
/** 
 * Reloads the stack views upon launching Recents.
 */
private void reloadStackView(){
  RecentsTaskLoader loader=Recents.getTaskLoader();
  RecentsTaskLoadPlan loadPlan=RecentsImpl.consumeInstanceLoadPlan();
  if (loadPlan == null) {
    loadPlan=loader.createLoadPlan(this);
  }
  RecentsConfiguration config=Recents.getConfiguration();
  RecentsActivityLaunchState launchState=config.getLaunchState();
  if (!loadPlan.hasTasks()) {
    loader.preloadTasks(loadPlan,launchState.launchedToTaskId,!launchState.launchedFromHome);
  }
  RecentsTaskLoadPlan.Options loadOpts=new RecentsTaskLoadPlan.Options();
  loadOpts.runningTaskId=launchState.launchedToTaskId;
  loadOpts.numVisibleTasks=launchState.launchedNumVisibleTasks;
  loadOpts.numVisibleTaskThumbnails=launchState.launchedNumVisibleThumbnails;
  loader.loadTasks(this,loadPlan,loadOpts);
  TaskStack stack=loadPlan.getTaskStack();
  mRecentsView.onReload(mIsVisible,stack.getTaskCount() == 0);
  mRecentsView.updateStack(stack,true);
  boolean animateNavBarScrim=!launchState.launchedViaDockGesture;
  mScrimViews.updateNavBarScrim(animateNavBarScrim,stack.getTaskCount() > 0,null);
  boolean wasLaunchedByAm=!launchState.launchedFromHome && !launchState.launchedFromApp;
  if (wasLaunchedByAm) {
    EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
  }
  if (launchState.launchedWithAltTab) {
    MetricsLogger.count(this,"String_Node_Str",1);
  }
 else {
    MetricsLogger.count(this,"String_Node_Str",1);
  }
  if (launchState.launchedFromApp) {
    Task launchTarget=stack.getLaunchTarget();
    int launchTaskIndexInStack=launchTarget != null ? stack.indexOfStackTask(launchTarget) : 0;
    MetricsLogger.count(this,"String_Node_Str",1);
    MetricsLogger.histogram(this,"String_Node_Str",launchTaskIndexInStack);
  }
 else {
    MetricsLogger.count(this,"String_Node_Str",1);
  }
  int taskCount=mRecentsView.getStack().getTaskCount();
  MetricsLogger.histogram(this,"String_Node_Str",taskCount);
  mIsVisible=true;
}