Skip to content

Fix full Cubism startup on macOS OpenGL core contexts - #99

Open
KevinGuo1007 wants to merge 197 commits into
vladelaina:mainfrom
KevinGuo1007:fix/issue-39-macos-startup
Open

KevinGuo1007 wants to merge 197 commits into
vladelaina:mainfrom
KevinGuo1007:fix/issue-39-macos-startup

Conversation

@KevinGuo1007

Copy link
Copy Markdown

Summary

📝 What's changed?

Addresses #39. A full Cubism build of source baseline 666999650f8afb405fa34dbf1ee0b98cd7145117 crashes during the standard model's texture-loading stage on macOS arm64. Initialize and validate GLEW after the context becomes current, then adapt the pinned renderer to the existing macOS OpenGL 4.1 core context.

current macOS OpenGL context:

  • initialize GLEW and validate required entries
  • load bundle Resources and build-local core shaders
  • draw through model-owned VAO/vertex/index buffers
  • restore caller context state

The repair keeps the SDK versions, graphics version, built-in models, public API and settings format unchanged. Generated SDK adaptations leave the installed SDK untouched. Two real-application CLI regressions check startup and the complete model/settings flow; a smoke-only selection fallback allows fresh built-in-only storage to exercise settings model changes.

Evidence

  • Before: unchanged full-Cubism Debug binary repeatedly exits with SIGSEGV (-11) at model-load:texture-loading:standard. LLDB observes a valid current context and empty framebuffer entries; calling only glewInit() fills those entries and removes the original crash. Successive real red runs expose missing shader resources, GLSL 1.20 incompatibility and client-array use in the core context.
    After: the final startup verifier still rejects the preserved original binary (-11, 0.718 s), and passes the repaired Debug binary (0, 2.524 s, 78/78 visible exact-standard frames, zero recorded GL errors) and Release binary (0, 2.104 s, 79/79 visible frames). A controlled missing-glBindFramebuffer debugger fault returns a named platform error, rolls the runtime count back to zero and exits cleanly with status 1.
  • Graphical regression: native macOS arm64 Debug and Release each display standard, keyboard and gamepad with intact textures and transparent regions. Both complete all 16 flow stages, including two settings-driven model changes, close/reopen, final recovery and normal exit. Saved model frames, alpha data and actual settings-window captures were inspected. An independent integrated Release replay passes in 24.801 s with 1,286 frames; the final shared-predicate verifier also passes the complete Release flow in 24.650 s with 1,292 frames against the same production binary.
  • Checks: full-runtime macOS CTest 6/6, diagnostic macOS 5/5 and full-runtime Linux 6/6. Full macOS arm64/x86_64 and Linux x86_64 builds pass with project warnings-as-errors. Mandatory policies, publishing-guard self-tests and CI-parity Ubuntu 24.04 Cppcheck 2.13 pass. An additional Cppcheck 2.22 run reports four unchanged baseline diagnostics; it is not a passing result. The last commit only extracts shared verifier predicates; it was checked with actual red/green/flow runs, Python syntax and line policy, without rebuilding unchanged application code.
  • Coverage limits: macOS x86_64 was cross-compiled only; Windows MSVC builds/runtime were unavailable. Linux application execution passes in emulated amd64 Xvfb/Mesa llvmpipe, not a physical desktop/GPU. The unchanged SDK emits vendor/deployment warnings. The latest public v1.14.0 arm64 archive also starts successfully and differs from the frozen source binary; the reported v1.8.0 archive returned 404 and was not run. Source repair evidence and release results are separate.

With the licensed pinned Cubism Native 5-r.5 SDK/GLEW 2.2.0 layout available, run serially on a graphical Mac with no other BongoCat instance (CUBISM_SDK points to that SDK):

cmake -S . -B build-issue39 -G Ninja -DCMAKE_BUILD_TYPE=Debug \
  -DCMAKE_OSX_ARCHITECTURES=arm64 -DBONGO_CAT_WARNINGS_AS_ERRORS=ON \
  -DBONGO_CAT_CUBISM_SDK="$CUBISM_SDK" -DBONGO_CAT_REQUIRE_CUBISM=ON
cmake --build build-issue39 --parallel
ctest --test-dir build-issue39 --output-on-failure
python3 tests/live2d/test_startup.py \
  build-issue39/BongoCat.app/Contents/MacOS/BongoCat new-startup-evidence
python3 tests/live2d/test_runtime_flow.py \
  build-issue39/BongoCat.app/Contents/MacOS/BongoCat new-flow-evidence

Output directories must be new. Repeat the build with Release and startup with --model=keyboard and --model=gamepad using separate output directories. Inspect captured model frames and the native settings UI; pixel counts alone do not establish texture correctness. The missing-entry negative path currently needs LLDB fault injection. Ordinary PR CI uses the diagnostic backend when the licensed SDK is absent and cannot prove this Cubism path.

Merge Danger

Door: Two-way

Revert the patch to restore previous behavior; no data migration or dependency upgrade is involved.

Blast Radius: Rendering

The new core-profile adapter and shader/resource staging are macOS-specific. Required-entry validation also runs on existing Windows/Linux GLEW paths, and frame diagnostics are shared. Remaining risk is unexecuted Windows/Intel Mac runtime coverage and SDK-sensitive generated-source anchors; the anchors fail configuration if the expected pinned source changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants