How to get the list of blocks for the current page? I'm trying to get the list of all blocks for a certain page, but I can't figure how to do that.

How do I get the list of all the blocks that are rendered for a page, independently from the region where they are put?
To get all blocks in an array by region, you can do as follow

// Get the current theme used
$theme = \Drupal::theme()-&gt;getActiveTheme()-&gt;getName();

// And pass the theme name to get all the regions
$regions = system_region_list($theme, $show = REGIONS_ALL);

// This will give you all the regions in array format
$regions =  json_decode(json_encode(system_region_list(\Drupal::config('system.theme')-&gt;get('default'),$show = REGIONS_ALL)),true);

// Loop over each regions
foreach ($regions as $key =&gt; $region) {
  // Get the blocks in particular region
  $blocks[$key] = \Drupal::entityManager()
    -&gt;getStorage('block')
    -&gt;loadByProperties([
      'theme' =&gt;  \Drupal::config('system.theme')-&gt;get('default'),
      'region'=&gt; $key,
    ]);
}