When clicking on the expand all, the angular.js script becomes unresponsive.
I have tried with both enabled and disabled js aggration and compression but no difference.
There are maybe 150 files and folders in the tree, maybe that is too much?
I have noticed this behaviour on Firefox, Chrome and IE.

As a workaround I have hidden the Expand/Collapse all context links.

Cheers, Joep

Screenshot unresponsive angular.js

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joep.hendrix created an issue. See original summary.

joep.hendrix’s picture

Issue summary: View changes
FileSize
98.27 KB
joep.hendrix’s picture

Issue summary: View changes
joep.hendrix’s picture

Issue summary: View changes
mpotter’s picture

I couldn't reproduce this on our site. I suppose it's possible it's an issue with a larger number of files. I have about 30 here in various taxonomy term folders. Are you getting any sort of Javascript error?

It's not doing anything back to the server for this...the files/folder widget isn't using Ajax and loads all of the file information for the entire display. So the Expand All is purely Javascript. Maybe you can use the Javascript profiler in Chrome to pin down where it is slow?

joep.hendrix’s picture

FileSize
306.37 KB

No errors in the console.
To be more precise: on Chrome there is no error, the script just seems to stop without expanding all directories.
Attached the screenshot of the profiler.

Chrome profiler output

joep.hendrix’s picture

Title: Expand all makes results in unresponsive script » Expand all results in unresponsive script
mpotter’s picture

Using the angular.min.js isn't going to tell us much I'm afraid since it minifies all the function names. I'll put this in the backlog but welcome help from anyone else who can debug this.

Argus’s picture

The amount of files isn't the issue. I have no problem with 150+ files.

joep.hendrix’s picture

Maybe it is related to the amount of folders that need to be expanded?

dureaghin’s picture

Angular ng-repeat is cause performance issues on large collections angular-tree-control.

I think it is better to switch over to Fancytree. Fancytree works very well for large trees.

mpotter’s picture

Except that FancyTree uses jQuery and this widget needs something that works well with AngularJS apps. The solution is probably some limit on how deep the ng-repeat goes or converting the entire script to only "fetch on demand" as folders are clicked.

dureaghin’s picture

We switched "ng-treecontrol" over to AngularJS UI Tree and it already works very well for large trees.

Thanks,
Alex.

joep.hendrix’s picture

@dureaghin: that is great news.
It would be nice if you could show us what steps you have taken to implement AngularJS UI Tree.

Thanks in advance!

dureaghin’s picture

Hi Joep Hendrix.
Sorry for the late reply, actually we had the same problem with "AngularJS UI Tree".

Aggregation, compression and Redis or Memcache not will help much to make "oa_files" module faster.

Currently we have around 1500 files in one file section and the first load takes around 1 minute without Memcache, with Memcache from 30 to 40 sec. Very easy to reproduce this in all Open Atrium releases.

Steps:
1. Create a new Space
2. Create a new Files Section
3. Create 100 folders with sub folder then upload for example 500 files to one of the folder then another 1000 files to other folders
4. Once folders and files added, reload the page
5. Now you should see the slowness

We fixed issue with ngRepeat directive when you click to expand all children nodes from the folders, now it works much faster. We integrated angular-vs-repeat into "oa_files" and "oa_angular" module. But the first time load is not related to the "angular-tree-control". We think the problem with "oa_files_treeview.inc", please check for example one of the function "oa_files_treeview_render". Looks like this function slowing everything and if you will comment this out then the first load will be faster because we're not making foreach for all the files from parent. The problem is because when you load the page it's querying all parent nodes and all children nodes, then menu links, then access, then files.

Also, something wrong with this code from "oa_files_treeview.inc" file:

  if ($mode == 0) {
    $parent_field = "menu_parent";
    $rearrange = url('/group/node/' . $space_id . '/admin/menu');
    $allownew = $allowfiles;
    // use Space Menu for tree
    $plid = og_menu_single_get_active_plid();
    if (isset($conf['og_menu_single_parent']) && ($conf['og_menu_single_parent'] == 'auto')) {
      $result = module_invoke_all('og_menu_single_menu_parent', $conf);
      if (!empty($result)) {
        $plid = reset($result);
      }
    }
    else if (!empty($conf['og_menu_single_parent'])) {
      $plid = $conf['og_menu_single_parent'];
    }

    drupal_add_js(array('oa_files' => array('node_token' => array('undefined' => drupal_get_token('add-node-undefined')))), 'setting');
    if ($plid) {
      // determine nid of menu parent
      $top_menu = menu_link_load($plid);
      if (!empty($top_menu['link_path']) && preg_match('#node/(\d+)#', $top_menu['link_path'], $matches) !== FALSE) {
        $conf['topid'] = $matches[1];
      }
      $menu_tree = og_menu_single_children_items($plid, !empty($conf['og_menu_single_depth']) ? $conf['og_menu_single_depth'] : MENU_MAX_DEPTH);
      if ($menu_tree) {
        $files = oa_files_prepare_files_from_menu($menu_tree, $conf);
      }
      if (!isset($conf['oa_files_all']) || $conf['oa_files_all']) {
        oa_files_add_uncategorized($files, $conf);
      }
      foreach ($files as $file) {
        // keys of arrays need to be strings or else javascript will rekey the numbers
        drupal_add_js(array('oa_files' => array('node_token' => array('node:' . $file['nid'] => drupal_get_token('add-node-' . $file['nid'])))), 'setting');
      }
    }
  }
  elseif ($mode == 1) {
    // use Vocabulary for tree
    $parent_field = 'term_parent';
    if ($user->uid == 0) {
      // always hide empty terms from anonymous users
      $conf['oa_files_hide_empty'] = TRUE;
    }
    $vid = $conf['oa_files_vocabulary'];
    $vocab = taxonomy_vocabulary_load($vid);
    $rearrange = $vocab ? url('admin/structure/taxonomy/' . $vocab->machine_name) : '';
    $terms = taxonomy_get_tree($vid);
    $allownew = FALSE;
    if (module_exists('og_vocab')) {
      $vids = og_vocab_get_accessible_vocabs('node', $node_type, OG_VOCAB_FIELD);
      if (!empty($vids) && in_array($vid, $vids)) {
        // check OG access for editing vocab terms
        $allownew = og_user_access('node', $space_id, "edit terms");
      }
    }
    if (!$allownew) {
      // otherwise check global permission for vocab
      $allownew = user_access('edit terms in ' . $vid);
    }
    $files = oa_files_prepare_files_from_vocab($terms, $conf, $allownew);
    // don't use numeric tokens for sparse javascript arrays or else they get rekeyed
    drupal_add_js(array('oa_files' => array('vocab_token' => array('vid:' . $vid => drupal_get_token('add-term-' . $vid)))), 'setting');
  }

We'll try to do more investigation on this and reply back with results.

Also, I can upload our changes so you can check what we did.

Thanks,
Alex.

dureaghin’s picture

Version: 7.x-2.45 » 7.x-2.618
Issue tags: +slow bad performance

Updated issue metadata to version 7.x-2.618, because this issue persist in all versions.

Thanks,
Alex.