T59047: performance issue (regression?)
https://developer.blender.org/T59047

Tests with default export options:
Tested on an old build I have on my laptop --> export in less than 1 minute
Tested with build of Dec 9th --> Still not finished after 15 minutes

We have to check if regression is on our side, or in blender api side
diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
index 06b60168..09e00862 100644
--- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
+++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
@@ -975,10 +975,10 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
 
         if max_index >= range_indices:
             #
-            # Spliting result_primitives.
+            # Splitting result_primitives.
             #
 
-            # At start, all indicees are pending.
+            # At start, all indices are pending.
             pending_attributes = {
                 POSITION_ATTRIBUTE: [],
                 NORMAL_ATTRIBUTE: []
@@ -1038,6 +1038,7 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
             while len(pending_indices) > 0:
 
                 process_indices = pending_primitive[INDICES_ID]
+                max_index = max(process_indices)
 
                 pending_indices = []
 
@@ -1046,7 +1047,7 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
 
                 all_local_indices = []
 
-                for i in range(0, (max(process_indices) // range_indices) + 1):
+                for i in range(0, (max_index // range_indices) + 1):
                     all_local_indices.append([])
 
                 #
@@ -1063,7 +1064,7 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
                                          process_indices[face_index + 2])
 
                     # ... check if it can be but in a range of maximum indices.
-                    for i in range(0, (max(process_indices) // range_indices) + 1):
+                    for i in range(0, (max_index // range_indices) + 1):
                         offset = i * range_indices
 
                         # Yes, so store the primitive with its indices.
@@ -1075,7 +1076,7 @@ def extract_primitives(glTF, blender_mesh, blender_vertex_groups, modifiers, exp
                             written = True
                             break
 
-                    # If not written, the triangel face has indices from different ranges.
+                    # If not written, the triangle face has indices from different ranges.
                     if not written:
                         pending_indices.extend([process_indices[face_index + 0], process_indices[face_index + 1],
                                                 process_indices[face_index + 2]])
['addons/io_scene_gltf2/blender/exp/gltf2_blender_extract.py']