Regalia v1.2.0 #41
YDW99
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
What's Changed
Full Changelog: v1.1.2...v1.2.0
Regalia v1.2.0 — Architecture Refactor Release
🎯 What's This Release About?
v1.2.0 is an architecture-level major version. The core theme: dismantling God Modules — splitting monolithic source files that had grown to 5,000+ lines into focused, single-responsibility modules — while preserving 100% backward compatibility and fixing every SonarCloud-reported defect.
No new user-facing features were added in v1.2.0 (those came in v1.0.4–v1.1.2). This release is about what's under the hood: cleaner code, safer code, and a foundation for faster feature development going forward.
📊 By the Numbers
StockfishNative.javalinesrenderInternal()lines🏗️ Architecture Changes
Java:
StockfishNative.javaGod Module Split (Phase 73)The 5,443-line
StockfishNative.java— which handled everything from engine process management to UCI protocol to PGN cache to file I/O to permissions to haptics — has been split into a Facade + 13 helper/manager classes:All 88
@JavascriptInterfacemethod signatures are preserved — the JS side calls the exact same methods as before. The Facade delegates internally to the appropriate helper class.JavaScript:
renderInternal()God Function Split (Phase 82)The 1,365-line
renderInternal()function — which built the entire app UI in one giant HTML string — has been split into 11 focused sub-functions:Additionally, 4 new JS modules were extracted from
ui.js:state-store.jsui-audio.jsui-board.jsui-review.jsui-toolbar.jsJS↔Java Message Bus (Phase 75)
A new
MessageBusclass provides a unified communication channel between JavaScript and Java, running alongside the existingAndroidBridge:Standard message types implemented:
ENGINE_GOENGINE_STOPENGINE_SET_OPTIONPGN_CACHE_SAVEENGINE_READYENGINE_BESTMOVEENGINE_EVALENGINE_ERRORPGN_CACHE_LISTThe MessageBus is registered as a separate
@JavascriptInterfacenamed"MessageBus". The JS-side receiver (window._messageBusJs._onEvent) dispatches events to theStorefor observability. All existingAndroidBridgemethods remain unchanged — the MessageBus is a parallel channel for future migration.Global State Store (Phase 75)
state-store.jsimplements a Redux-like single source of truth:The Store is wired as a debug observability layer — global variables remain the source of truth, and Store mirrors state changes at key points (
_resetGameUIState,toggleLang,toggleSound,enterReview, and all MessageBus events).🔒 SonarCloud Defect Resolution
42 Bugs Fixed
InterruptedExceptionre-interruptThread.currentThread().interrupt()in all catch blocksdelete()/renameTo()return value==/!=strict equality===/!==AtomicIntegerfor atomic fieldsvolatile intwithAtomicInteger5 Vulnerabilities Fixed
Math.random()for Chess960 SP-IDcrypto.getRandomValues()+ fallbackunsafe-inlineevaluationloadAssetAsBase64..path traversal check1,892 Code Smells Fixed
_buildPGNString(439→7 helpers),_computeAndCacheVisualAnnotations(439→4 helpers),_buildEvalTrendSVG(267→6 helpers)?.) replacing&&short-circuitString.replaceAlloverString.replacewith regexfor-ofloops over indexedforloops♟️ Review Board Coordinate Labels (Phase 77)
The review board now displays coordinate labels matching the main board and stats page:
All labels use
position: absoluteas siblings of.bgrid(not inside it) — this avoids breaking the CSS Grid's 64-cell layout (a regression introduced and fixed in Phase 77→83).🐛 Critical Bug Fixes (v1.2.0-specific)
Review Mode Entry Failure (Phase 82++++)
Root cause: The Phase 82++ extraction moved
const flip = playerColor === 'black'into_renderHeader()(local scope), but_renderReviewMode()referencedflip9 times as a free variable →ReferenceError→ caught by try-catch → "Render Error" instead of the review overlay.Fix: Extracted
_computeRenderState()returning{cm, infoSq, infoCtrl, oppC, flip}, passed explicitly to all sub-functions.Layout Regression — Game-Over Overlay (Phase 82+++++)
Root cause: The
.goveroverlay usesposition: absolute; inset: 0and anchors to.bwrap(position: relative). The extraction accidentally moved the game-over overlay outside.bwrap, causing it to cover the entire screen instead of just the board.Fix: Reordered
renderInternalto match v1.1.2 — overlay and setup panel render inside.bwrap, before the</div></div>close.Stats Page Visual Annotations (Phase 82+++++ rev 9)
Root cause:
_buildPGNString()filtered out auto-generated annotations (imported=false) per Phase 62 design. This was correct for PGN export, butopenStatsPage()also called it without a way to include auto-generated annotations — so the stats page never received live-game visual annotations.Fix: Added
includeAutoAnnotationsparameter (defaultfalse).openStatsPage()passestrue. PGN export flows unchanged.MessageBus Reflection Failure in Release (Phase 82+++++ rev 8)
Root cause:
setMessageBusWebView()used reflection to set a private field. R8 (minifyEnabled true) renamed the field, causingNoSuchFieldException. AllemitToJs()calls were silently dropped in release builds.Fix: Replaced reflection with a public
setWebView()method. Createdproguard-rules.prowith keep rules.📦 Build & Security
ProGuard/R8 Rules
v1.2.0 adds
proguard-rules.pro(previously referenced bybuild.gradlebut missing):WebView Cache Invalidation
MainActivity.onCreate()now callswebView.clearCache(true)beforeloadUrl()— ensuring the latestchess.htmlis always loaded from the APK after updates (critical for Xiaomi HyperOS which aggressively caches).Sandbox Path Hardening
JsBridgeGateway.isPathInSandbox()tightened to require a path separator after the sandbox root — preventing/data/data/com.Regalia/files_evilfrom being accepted as insidefilesDir.📁 File Structure (v1.2.0)
📥 Download
Regalia-v1.2.0-release.apkRegalia-v1.2.0-manual-zh.htmlRegalia-v1.2.0-manual-en.htmlAPK Verification
🔄 Upgrade Path
🙏 Acknowledgments
📜 License
Regalia is a combined work under dual licensing:
Per GPL v3 Section 13, these licenses are compatible for combination. AGPL v3's network interaction provisions extend to the entire combined work.
Full license texts:
LICENSE-AGPL v3,LICENSE-GPL v3,LICENSE-Apache v2.0🔗 Links
v1.2.0 — Built with JDK 21, Android SDK 35, NDK 27.2, CMake 3.22.1. Tested on Xiaomi HyperOS 3.
AI-GEN
This discussion was created from the release Regalia v1.2.0.
All reactions