Repository navigation
Conversation
cvcGL and the pycvc bindings kept process-wide state: scene node types and shader presets, the transfer-function bindings, the UI font settings, the low-memory mapper's policy, draw path and shared shader sources, the X11 clipboard connection, SDL's window and timer routes, the props marked as casting no shadow, the flushing publisher, the JPEG handles and constant tables built at first use. Each now lives on the cvc::app (app.slot<T>()), in the object that uses it, in the SDL window it describes, or in read-only data. cvcGL: - Scene node types and shader presets are the app's (scene_realize.cpp): register_scene_node_type, has_scene_node_type, register_shader_preset, has_shader_preset, register_default_shader_presets and verify_scene_customs take the app, as do the registrars that call them (register_lsystem_node_types, register_mesh_node_types, register_world_node_types, register_vehicle_preview_node, register_stream_node_type). A scene realizes only its own app's types and presets. - tf_binding: the live bindings, the seeds and the overlay_status owners, and the owner-tag counter, are the app's (they were keyed by app pointer in a process-wide map). idle_status's "unavailable: " is a constexpr string_view. - tf_editor_imgui: the stand-in default model and overlays are built per call. - ImGuiOverlay: the UI font settings are the app's (setUiFontPath / setUiFontFallbacks / setUiFontMemory / loadUiFonts take the app). The clipboard buffer handed to ImGui is the overlay's. A failed ImGui_ImplOpenGL3_Init is remembered per overlay, and clears imgui's GL loader table (imgl3wShutdown, as ImGui_ImplOpenGL3_Shutdown does) so a later overlay's Init fails cleanly instead of crashing on a null GL_VERSION: that was why g_glBackendFailed had to be process-wide. - Clipboard: clipboard::set/get take the app; on X11 the app holds its own X connection (closed with the app). Backend::set_clipboard takes the document's app (the core passes the Runtime's). - LowMemoryPolyDataMapper: the policy, draw path, pass-program switch and stage observer are the app's, read from the environment when the app's settings are first used; a mapper draws by the settings of the app newPolyDataMapper(app) (or a node's setApp) gave it, and shares its shader source copies with that app's mappers. newPolyDataMapper, setLowMemoryMapperPolicy, lowMemoryMapperPolicy, setDrawPath/drawPath, setPassProgramsEnabled/passProgramsEnabled and setStageObserver take the app. BBoxNode and RenderView take the app for it. - SdlWindow: which SDL windows are cvcGL's (openWindows) and whose events each window's are are SDL window properties, not process-wide tables; a timer tick goes to the interactor whose timers have its id. The registered timer event type is an SDL resource of the process (SDL_RegisterEvents gives each type once and none back), so it is kept in SDL's own global properties. The cursor and punctuation tables are constexpr. - GraphicsNode: the shadow non-caster mark is the app's (setPropCastsShadow / propCastsShadow take the app); it was a process-wide VTK information key. The shadow passes ask their scene's app. - state_publisher: which publisher is flushing on a thread is kept by the app (flushing(app) / in_flush(app)), not in thread-locals. - VolumeNode: its own transfer-function writes in progress are the node's (with the writing thread), not a thread-local; the first-call log is per node. - jpeg_codec: jpeg_encoder / jpeg_decoder objects own their TurboJPEG handles (the encode source and the stream view's decoder keep theirs) instead of thread-local handles. - GeometryNode / VolumeNode computed keys, SdlInput's key names, StageLighting's gizmo names: in constexpr tables. TouchScroll's ImGui ids are hashed per call. ViewportManager sets VTK's output window each time instead of once behind a static flag. pycvc / pycvc_gl: - The enum classes, exception types, dsl_error factory and the kept `who` names live on the _pycvc module object (found through the interpreter's dict), not in C statics. - symbol_swig_type / value_swig_type / async_call_to_py use SWIG's own type-table entries. - The capsule names are constexpr. - Exec's "a run() is active on this thread" mark and pycvc_gl's deferred rung-style error are kept in Python's per-thread state (PyThreadState_GetDict), not in C++ thread-locals. Tests: - cvcgl_multi_app (new, headless): a workload of node types, shader presets, mapper settings, shadow marks, publisher flushes and JPEG codecs, alone, on threads at once and in reverse order, plus a later app starting clean and per-app UI fonts. - cvcgl_state_publisher: flushing is per app (nested both ways, on threads at once, a later app). - cvcgl_lowmem_fastdraw: another app keeps its own policy and draw path. - cvcgl_shadow_casters: a non-caster mark is its app's alone. - test_pycvc_app.py: two apps' module state (enums, exceptions, dsl_error, kept names, the running-Exec mark) alone, in either order and on threads. - Tests that relied on process-wide registrations now register on their own app. Allowlist: 103 lines removed (cvcGL 76, pycvc 26, pycvc_gl 1).
This was referenced Nov 12, 2026
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No singletons, cvcGL and pycvc: registries, settings and caches per app. Stacked on #1176 (Ariadne part 3); a sibling of #1182, #1183 and #1184. Breaking (4.0).
All of cvcGL's and pycvc's own process-wide state is gone. What remains in their allowlist sections:
_useThreadinglines, which No singletons, state: startup hooks, default shard, codecs and threading per app [4.0, breaking] #1182 removes;state_execnil/true/false values, which the state_exec PR removes.What moved
app.slot):register_scene_node_type,has_scene_node_type,register_shader_preset,has_shader_preset,register_default_shader_presets,verify_scene_customs, and the lsystem, mesh, world, vehicle-preview and stream node registrars);ImGuiOverlay::setUiFontPath/setUiFontFallbacks/setUiFontMemory/loadUiFonts);LowMemoryPolyDataMapper::setApp: GeometryNode sets it; a mapper with no app uses its environment defaults;BBoxNode(app),RenderView(app, ...));clipboard::set/get, and the core'sBackend::set_clipboard(app, text));GraphicsNode::setPropCastsShadow/propCastsShadow: a table per app replaces the VTK information key);state_publisher::flushing/in_flush).g_glBackendFailedis per overlay. A failedImGui_ImplOpenGL3_Initalso callsimgl3wShutdown(), so a later overlay fails cleanly instead of crashing on a nullGL_VERSION; that crash was why the flag had been process-wide.jpeg_encoder/jpeg_decoderown their TurboJPEG handles.constexpr;timers_holds its id;SDL_RegisterEvents, a per-process SDL resource that is never returned) is registered once and kept in SDL's own global properties, not in a static of ours._pycvcmodule object;SWIGTYPE_p_*table;constexpr;PyThreadState_GetDictinstead of C++ thread_locals.Allowlist: -103 lines (cvcGL 76, pycvc 26, pycvc_gl 1)
<header>tf_binding::impl::idle_status()::headand its guard.pycvcPYTHON_wrap.cxx's lines andpycvc_exec.cpp'st_running_exec.gl_lod::style_error()::e.Not removed
imgui_impl_opengl3.cpp(the GL function tableimgl3wProcs, the loader handles,version) andimgui_freetype.cpp(allocator and loader hooks), 11 lines. They are compiled into cvcGL from the deps bundle, not from libcvc's sources. They are third-party; a follow-up adds a source-path rule toscan.py's third-party list for them.Tests
cvcgl_multi_app(new, headless). Each app registers its own node type and shader preset and realizes only its own: another app's type and preset only warn. It also covers the customs gate, mapper settings, shadow marks, publisher flushes and the JPEG codec. It runs alone, on threads at once and in reverse order; a later app starts clean, and UI fonts are per app.cvcgl_state_publisher(flushing per app),cvcgl_lowmem_fastdraw(another app keeps its own policy and draw path),cvcgl_shadow_casters(a mark is its app's alone), andtest_pycvc_app.py(module state for several apps, in either order and on threads).cvcgl_ariadne_physicsand the other cvcGL tests register on their own app;cvcgl_lowmem_fastdraw's probe mappers andcvcgl_lowmem_bench's TallyMapper callsetApp.Locally (Windows, MSVC Release; the whole tree builds):
ctest -R ^cvcgl_105/105,ctest -R pycvc64/64,ctest -R ^arigl(10 pass, 5 skipped);app_test121,multi_app_integration_test2;ariadne_runtime_test,ariadne_requires_test,ariadne_media_testandjob_intrinsics_test(becausebackend.hchanged).The X11 clipboard branch is not compiled on Windows; the Linux CI builds it.
CI
Full run: the push to
ci/full/no-singletons-cvcgl, https://github.com/transfix/libcvc/actions/runs/43212922516.