Skip to content

Refactors lwjgl processing#19

Merged
blarfoon merged 2 commits intomasterfrom
make-lwjgl-inline
Oct 19, 2025
Merged

Refactors lwjgl processing#19
blarfoon merged 2 commits intomasterfrom
make-lwjgl-inline

Conversation

@blarfoon
Copy link
Member

@blarfoon blarfoon commented Oct 19, 2025

Summary by CodeRabbit

  • Refactor
    • Removed LWJGL variant–specific management and validation; LWJGL handling is now applied through the generic library patching flow so libraries are treated uniformly.
  • Chores
    • Removed legacy LWJGL native configuration data and related variant metadata.

@coderabbitai
Copy link

coderabbitai bot commented Oct 19, 2025

Walkthrough

The PR removes LWJGL-specific configuration and processing: deletes daedalus_client/lwjgl-config.json, removes the lwjgl.rs module and LWJGL types, and integrates LWJGL handling into generic library patching by eliminating variant detection and variant-specific manifest uploads. No LWJGL public types or module exports remain.

Changes

Cohort / File(s) Summary
Config removed
daedalus_client/lwjgl-config.json
Entire JSON config defining accept/reject native matchers for LWJGL versions deleted.
LWJGL module removed
daedalus_client/src/minecraft/lwjgl.rs
Deleted module that processed LWJGL variant groups, validated classifiers, applied LWJGL-specific patches, and managed variant uploads.
Integration & API updates
daedalus_client/src/minecraft/mod.rs
Removed pub mod lwjgl;, removed LWJGL variant tracking/processing from retrieve_data() flow, replaced per-variant logic with generic patch application and updated function signature/returns to use manifest builder and s3_client.
Type removals
daedalus_client/src/minecraft/types.rs
Removed public structs LWJGLVariantMarker and LWJGLVariantConfig (and their Deserialize fields). LibraryPatch remains exported.

Sequence Diagram(s)

sequenceDiagram
    participant Client as "retrieve_data()"
    participant Patcher as "Library Patcher"
    participant Store as "Manifest / S3"

    rect rgb(240, 255, 240)
    Note over Client,Patcher: Before (old flow with LWJGL variants)
    Client->>Client: create LWJGL variant buckets
    Client->>Patcher: call lwjgl-specific processing
    Patcher->>Patcher: validate native classifiers & decide accept/reject
    alt accepted
        Patcher->>Store: upload LWJGL-specific artifacts
        Store->>Client: update manifest with variant entry
    end
    end

    rect rgb(255, 250, 240)
    Note over Client,Patcher: After (new flow)
    Client->>Patcher: apply generic library patches to all libraries
    Patcher->>Store: upload patched libraries uniformly
    Store->>Client: update manifest without LWJGL-specific variant entries
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

I nibbled configs in the glen,

The JSON and module—gone again.
Variants hopped off, quiet and sweet,
Patches now trail a single beat.
—a rabbit applauds the tidy feat 🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Refactors lwjgl processing" directly and accurately describes the main objective of the changeset. The PR removes the entire LWJGL variant processing system (lwjgl.rs module, lwjgl-config.json, and related types) and integrates LWJGL handling into the generic library patching flow within mod.rs. The title is concise, specific, and avoids vague or misleading language. A developer reviewing the git history would immediately understand that this change concerns how LWJGL is processed in the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch make-lwjgl-inline

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbb9acb and dd3925f.

📒 Files selected for processing (1)
  • daedalus_client/src/minecraft/mod.rs (6 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
daedalus_client/src/minecraft/mod.rs (4)
daedalus/src/lib.rs (2)
  • download_file (391-433)
  • new (69-82)
daedalus_client/src/minecraft/library_patches.rs (3)
  • patches (19-22)
  • get_library_patches (59-64)
  • patch_library (16-56)
daedalus/src/minecraft.rs (1)
  • fetch_version_info (747-753)
daedalus_client/src/minecraft/log4j.rs (2)
  • map_log4j_artifact (21-39)
  • create_log4j_replacement_library (55-123)
🔇 Additional comments (6)
daedalus_client/src/minecraft/mod.rs (6)

1-28: Documentation accurately reflects the refactored architecture.

The module documentation and public exports have been correctly updated to reflect that LWJGL processing is now handled via generic library patching rather than as a separate module. The removal of LWJGL-specific types from public exports is consistent with the PR objectives.


30-40: LGTM! Import changes align with the refactoring.

The addition of join_all for concurrent chunk processing and the simplified tracing imports are appropriate for the refactored code structure.


42-70: Function signature and documentation correctly updated.

The new parameters (manifest_builder, s3_client) and return type (VersionManifest) are properly documented and used throughout the function. The documentation clearly explains that LWJGL libraries are now handled inline via generic patching.


90-91: Excellent use of Arc to avoid lifetime issues in futures.

Owning the patches and converting them to Arc<[LibraryPatch]> is a clean solution that allows safe sharing across the async futures without lifetime complications.


335-372: Chunk processing with join_all is correctly implemented.

The concurrent chunk processing is well-designed:

  • join_all processes versions in parallel (controlled by the semaphore for I/O)
  • Error handling logs failures but continues processing, which is appropriate for batch operations
  • Progress logging provides clear visibility into success/failure rates

374-396: Finalization correctly uses set_loader_versions to preserve metadata.

The approach of using set_loader_versions() with the full VersionManifest (rather than adding versions individually) correctly preserves rich metadata like type, URL, timestamps, and sha1 hashes. The comment on lines 323-325 clearly explains this design decision.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (4)
daedalus_client/src/minecraft/mod.rs (4)

155-157: Avoid Arc<&Vec<_>>; hold patches as Arc<[LibraryPatch]> and pass slices explicitly.

Current setup uses Arc<&Vec<_>> captured across async tasks; this is non‑idiomatic and fragile. Store patches as an owned Arc and pass &[LibraryPatch] to patch_library.

Apply this at callsite:

-                        let mut libs = library_patches::patch_library(&patches, library.clone());
+                        let mut libs = library_patches::patch_library(Arc::as_ref(&patches), library.clone());
                         new_libraries.append(&mut libs);

And make these supporting changes outside this hunk:

@@
-    let patches = library_patches::get_library_patches().await?;
-    let cloned_patches = Arc::new(&patches);
+    // Own the patches and share as an Arc slice to avoid borrowed refs in futures
+    let patches: Arc<[LibraryPatch]> =
+        Arc::from(library_patches::get_library_patches().await?.into_boxed_slice());
@@
-            let patches = Arc::clone(&cloned_patches);
+            let patches = Arc::clone(&patches);

Rationale: patch_library takes &[LibraryPatch] (see library_patches.rs), so Arc::as_ref(&patches) cleanly yields a slice without relying on layered deref coercions. Based on relevant code snippet in library_patches.rs.


137-151: Also patch the Log4j replacement (or confirm no rules target Log4j).

Right now, Log4j libs are either replaced or passed through unmodified. If any LibraryPatch rules target Log4j artifacts, they won’t run for the replaced case.

Minimal change:

-                            let replacement_library = log4j::create_log4j_replacement_library(
+                            let mut replacement_library = log4j::create_log4j_replacement_library(
                                 &spec.artifact,
                                 &version_override,
                                 &maven_override,
                                 library.include_in_classpath,
                             )?;
-                            new_libraries.push(replacement_library);
+                            // Mark for traceability and run through patcher for consistency
+                            replacement_library.patched = true;
+                            let mut libs = library_patches::patch_library(
+                                Arc::as_ref(&patches),
+                                replacement_library,
+                            );
+                            new_libraries.append(&mut libs);

If you intentionally excluded Log4j from patch rules, please confirm and we’ll keep the current flow. Based on relevant code snippet in library_patches.rs.


46-50: Doc tweak: clarify LWJGL “fixes” vs removed variant processing.

To avoid confusion now that variant infra is removed, consider clarifying that LWJGL “fixes” are handled via generic library patches, not variant detection.

Example:

  • “Applies library patches (e.g., LWJGL-related fixes; no LWJGL variant processing).”

333-346: Run each chunk concurrently (join_all or FuturesUnordered) for speed.

Within each chunk you await futures sequentially. To actually process up to 100 versions in parallel (and still rely on the semaphore for I/O backpressure), consider join_all.

Sketch:

@@
-            for future in chunk {
-                match future.await {
+            for result in futures::future::join_all(chunk).await {
-                    Ok(_) => {
+                match result {
                     Ok(_) => {
                         successful += 1;
                     }
                     Err(e) => {
                         warn!("⚠️  Minecraft - Failed to process version: {}", e);
                         failed += 1;
                     }
                 }
             }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62c449d and bbb9acb.

📒 Files selected for processing (4)
  • daedalus_client/lwjgl-config.json (0 hunks)
  • daedalus_client/src/minecraft/lwjgl.rs (0 hunks)
  • daedalus_client/src/minecraft/mod.rs (5 hunks)
  • daedalus_client/src/minecraft/types.rs (0 hunks)
💤 Files with no reviewable changes (3)
  • daedalus_client/lwjgl-config.json
  • daedalus_client/src/minecraft/types.rs
  • daedalus_client/src/minecraft/lwjgl.rs
🧰 Additional context used
🧬 Code graph analysis (1)
daedalus_client/src/minecraft/mod.rs (2)
daedalus_client/utils/restore_split_natives.py (1)
  • LibraryPatch (297-306)
daedalus_client/src/minecraft/library_patches.rs (2)
  • patch_library (16-56)
  • patches (19-22)
🔇 Additional comments (2)
daedalus_client/src/minecraft/mod.rs (2)

28-28: Public API change: confirm downstream impact and changelog.

Re-exports now surface only types::LibraryPatch. If consumers previously imported LWJGL types from this module, this is breaking. Add a changelog note and, if applicable, a semver bump.


118-118: Nice: centralized library processing path.

Routing all non‑Log4j libs through patch_library keeps LWJGL fixes alive post‑refactor and simplifies the flow.

@blarfoon blarfoon merged commit 8e5ca4e into master Oct 19, 2025
3 checks passed
@blarfoon blarfoon deleted the make-lwjgl-inline branch October 19, 2025 06:54
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.

1 participant