@volter/blender-engine 0.1.47 → 0.1.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/browser/session.py +32 -1
  2. package/package.json +1 -1
@@ -143,6 +143,25 @@ REPLY = os.path.join(ROOT, "reply")
143
143
  # (`blender-wali-engine.mts`), where the file is not a fallback but the
144
144
  # native door onto the same bytes.
145
145
  EXPORT_BUFFER_PATH = os.environ.get("VOLTER_EXPORT_BUFFER_PATH", "")
146
+
147
+ # WHERE THE ENGINE'S HEAP WENT, stage by stage: the heap only grows, so its size after a stage says
148
+ # nothing about the stage before it; this records `_blender_web.memory()` at each, in MB
149
+ # ([label, heap, mallocInUse, mallocFree, guarded, guardedPeak]), and a script reads `MEMORY_MARKS`
150
+ # (the last 64) to say which stage raised the high-water mark. MEASURED 2026-09-29 on the
151
+ # Stoneguard file: the first export's door call took the heap from 1,442 to 3,644 MB while in-use
152
+ # rose 28 MB and the guarded peak did not move -- OpenSubdiv's limit-surface evaluator for one
153
+ # head (quality 3), which native Blender pays too (+1.2 GB peak RSS there).
154
+ MEMORY_MARKS = []
155
+
156
+
157
+ def _mark(label):
158
+ try:
159
+ reading = _blender_web.memory()
160
+ except Exception: # noqa: BLE001 -- an engine without the door records nothing
161
+ return
162
+ MEMORY_MARKS.append([label] + [round(reading.get(key, 0) / 1048576)
163
+ for key in ("heap", "mallocInUse", "mallocFree", "guarded", "guardedPeak")])
164
+ del MEMORY_MARKS[:-64]
146
165
  _real_stderr = sys.stderr
147
166
 
148
167
 
@@ -1358,6 +1377,7 @@ class Session:
1358
1377
  """
1359
1378
  scene = bpy.context.scene
1360
1379
  graphs = material_graphs(scene)
1380
+ _mark("export:graphs")
1361
1381
  # An IMAGE EMPTY's picture travels with the graphs' images: the overlay draws it
1362
1382
  # (`overlay_empty.hh` `image_sync`).
1363
1383
  empty_images = {obj.data.name for obj in scene.objects
@@ -1378,7 +1398,13 @@ class Session:
1378
1398
  # An engine without the pull door ships them all in this call, as before.
1379
1399
  if hasattr(_blender_web, "export_mesh"):
1380
1400
  options["defer"] = True
1381
- frame = json.loads(_blender_web.export_frame(json.dumps(options)))
1401
+ if hasattr(_blender_web, "memory_reset_peak"):
1402
+ _blender_web.memory_reset_peak()
1403
+ exported = _blender_web.export_frame(json.dumps(options))
1404
+ _mark("export:door")
1405
+ frame = json.loads(exported)
1406
+ del exported
1407
+ _mark("export:parsed")
1382
1408
  error = frame.get("error")
1383
1409
  if error:
1384
1410
  raise RuntimeError("Blender export door: %s" % error)
@@ -1507,8 +1533,11 @@ class Session:
1507
1533
 
1508
1534
  def _present(self, capture=None):
1509
1535
  known = dict(self._known)
1536
+ _mark("present:before")
1510
1537
  frame = self._export()
1538
+ _mark("present:exported")
1511
1539
  pulled = self._pull(frame)
1540
+ _mark("present:pulled")
1512
1541
  self._drop_unreachable_textures(frame)
1513
1542
  # WHAT THIS FRAME SHIPPED, for the session's own accounting: the ids
1514
1543
  # whose columns crossed, and the ids that went as a reference. The
@@ -1816,7 +1845,9 @@ class Session:
1816
1845
  self.document = os.path.join(self.project, relative_path)
1817
1846
  if not os.path.exists(self.document):
1818
1847
  return {"document": relative_path, "opened": False}
1848
+ _mark("open:before")
1819
1849
  bpy.ops.wm.open_mainfile(filepath=self.document)
1850
+ _mark("open:after")
1820
1851
  size = os.path.getsize(self.document)
1821
1852
  # THE STAGED COPY GOES ONCE BLENDER HAS READ IT. It sits in the engine's heap (WasmFS keeps
1822
1853
  # file data in linear memory) and nothing reads it again: the load took everything into
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@volter/blender-engine",
3
3
  "author": "Volter AI, Inc.",
4
4
  "license": "GPL-3.0-or-later",
5
- "version": "0.1.47",
5
+ "version": "0.1.48",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },