Logging prevents GLTF from lazy loading modules (27x load time for the add-on)
See original GitHub issueBlender has a convention of lazy loading modules for faster startup times,
GLTF mostly follows this however importing GLTF logging pulls in many other modules, since GLTF is enabled by default, it should not be imposing a startup cost, even if its a small one since it impacts startup for automation, render farms, tests, etc.
This can be avoided by having the logging levels in the file, or even making this a developer only feature since very few users would be interested in this - you could use bpy.app.debug_value
or some other method to set the levels.
This is a list of modules loaded with times, using:
PYTHONPROFILEIMPORTTIME=1 ./blender.bin --factory-startup
import time: self [us] | cumulative | imported package
--- snip ---
import time: 664 | 1140 | io_scene_3ds
import time: 1344 | 1344 | io_scene_fbx
import time: 395 | 395 | io_anim_bvh
import time: 348 | 348 | io_mesh_ply
import time: 388 | 388 | io_scene_obj
import time: 349 | 349 | io_scene_x3d
import time: 386 | 386 | io_mesh_stl
import time: 435 | 435 | io_mesh_uv_layout
import time: 257 | 257 | io_curve_svg
import time: 205 | 205 | io_scene_gltf2.io.imp
import time: 231 | 435 | io_scene_gltf2.io
import time: 176 | 610 | io_scene_gltf2.io.com
import time: 152 | 152 | time
import time: 1172 | 1172 | enum
import time: 98 | 98 | _sre
import time: 536 | 536 | sre_constants
import time: 727 | 1263 | sre_parse
import time: 534 | 1893 | sre_compile
import time: 306 | 306 | copyreg
import time: 854 | 4224 | re
import time: 323 | 323 | token
import time: 1471 | 6017 | tokenize
import time: 321 | 6338 | linecache
import time: 590 | 6928 | traceback
import time: 346 | 346 | _weakrefset
import time: 668 | 1014 | weakref
import time: 209 | 209 | collections.abc
import time: 52 | 52 | _string
import time: 1241 | 1293 | string
import time: 895 | 895 | threading
import time: 50 | 50 | atexit
import time: 1505 | 11891 | logging
import time: 271 | 12923 | io_scene_gltf2.io.com.gltf2_io_debug
import time: 515 | 13437 | io_scene_gltf2
With the import removed: from .io.com.gltf2_io_debug import Log
.
import time: self [us] | cumulative | imported package
--- snip ---
import time: 664 | 1145 | io_scene_3ds
import time: 1372 | 1372 | io_scene_fbx
import time: 390 | 390 | io_anim_bvh
import time: 351 | 351 | io_mesh_ply
import time: 389 | 389 | io_scene_obj
import time: 353 | 353 | io_scene_x3d
import time: 390 | 390 | io_mesh_stl
import time: 432 | 432 | io_mesh_uv_layout
import time: 258 | 258 | io_curve_svg
import time: 486 | 486 | io_scene_gltf2
Patch to test:
diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 20afb1d9..d9d2e6e1 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -22,7 +22,7 @@ import bpy
from bpy_extras.io_utils import ImportHelper, ExportHelper
from bpy.types import Operator, AddonPreferences
-from .io.com.gltf2_io_debug import Log
+# from .io.com.gltf2_io_debug import Log
from bpy.props import (CollectionProperty,
StringProperty,
@@ -442,11 +442,11 @@ class ImportGLTF2(Operator, ImportHelper):
filter_glob: StringProperty(default="*.glb;*.gltf", options={'HIDDEN'})
- loglevel: EnumProperty(
- items=Log.get_levels(),
- name="Log Level",
- description="Set level of log to display",
- default=Log.default())
+ # loglevel: EnumProperty(
+ # items=Log.get_levels(),
+ # name="Log Level",
+ # description="Set level of log to display",
+ # default=Log.default())
import_pack_images: BoolProperty(
name='Pack images',
@@ -525,4 +525,3 @@ def unregister():
# remove from the export / import menu
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
-
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Lazy-loading feature modules - Angular
Setting up a lazy-loaded feature module requires two main steps: Create the feature module with the Angular CLI, using the --route flag. Configure...
Read more >Lazy Loading | webpack
The trouble is that no user interaction is required to load the bundle – meaning that every time the page is loaded, the...
Read more >Lazy-loading modules - A progressive Node.js framework
By default, modules are eagerly loaded, which means that as soon as the application loads, so do all the modules, whether or not...
Read more >Lazy loading React components - LogRocket Blog
Learn how to apply code-splitting and lazy loading to React components with React.lazy() and React.Suspense.
Read more >Lazy-load | Drupal.org
This is a simple Drupal module which lets you enable lazy-loading images and iframes. This module depends on the lazysizes library.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ideasman42 : Thanks Campbell. Is there any convention and/or list of already used values for bpy.app.debug_value? Or we can choose any wanted values?
I will manage it ASAP
Because the initial problem is now solved (lazy loading time), I propose to close this issue, and continue discussion on #89 when bpy.app.log_level will be available