Skip to content

Use RapidXMLParser to resolve LibXMLParser::xmlCleanupParser crash #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

apparition47
Copy link

@apparition47 apparition47 commented Apr 2, 2025

Having this issue: SDWebImage/SDWebImageSVGNativeCoder#14

Seems to be resolved by using RapidXMLParser instead in my testing

Summary by CodeRabbit

  • Chores
    • Updated the native SVG package’s build configuration by revising the exclusion rules for XML parser components, ensuring a more streamlined integration.

Copy link

coderabbitai bot commented Apr 2, 2025

Walkthrough

This pull request updates the file exclusion settings for the svgnative package. In both the Package.swift and svgnative.podspec files, the previously excluded XML parser file (RapidXMLParser.cpp) has been replaced with a new exclusion for (LibXMLParser.cpp), thereby updating the build configuration for the package.

Changes

File(s) Change Summary
Package.swift
svgnative.podspec
Updated XML parser exclusion: removed svgnative/.../RapidXMLParser.cpp (or svg-native-viewer/svgnative/.../RapidXMLParser.cpp) and added exclusion for svgnative/.../LibXMLParser.cpp.

Poem

I'm a little rabbit, hopping in the code,
Switching files along a thoughtful mode.
Rapid takes a bow as Lib steps into play,
In swift and podspec, the changes find their way.
With whiskers twitching and paws so light,
I celebrate this tweak by leaping into the night!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🔭 Outside diff range comments (1)
svgnative.podspec (1)

61-61: 💡 Verification agent

🧩 Analysis chain

Verify XML library dependency with RapidXMLParser

I notice that even after switching to RapidXMLParser, the project still includes 'xml2' as a library dependency. This is worth verifying.


🏁 Script executed:

#!/bin/bash
# Check if RapidXMLParser relies on libxml2
echo "Checking RapidXMLParser.cpp for libxml2 dependencies..."
find svg-native-viewer -name "RapidXMLParser.cpp" | xargs cat | grep -n "libxml" || echo "No direct libxml references found in RapidXMLParser.cpp"

echo "Checking RapidXMLParser.cpp for includes..."
find svg-native-viewer -name "RapidXMLParser.cpp" | xargs cat | grep -n "#include" || echo "No includes found in RapidXMLParser.cpp"

Length of output: 589


XML Library Dependency in svgnative.podspec

Based on the grep checks in RapidXMLParser.cpp, there are no references to "libxml" or any #include statements suggesting that RapidXMLParser relies on libxml2. Unless another part of the project still depends on xml2, it appears that the 'xml2' entry in the s.libraries list may no longer be necessary. Please verify that no other modules require libxml2 before removing it from the podspec.

  • Confirmed: No direct "libxml" string found in RapidXMLParser.cpp.
  • Confirmed: No #include statements indicating libxml2 dependency.
🧹 Nitpick comments (2)
Package.swift (1)

30-30: Change looks good - switching to RapidXMLParser implementation

This change excludes LibXMLParser.cpp instead of RapidXMLParser.cpp, effectively switching the XML parser implementation to use RapidXMLParser. This aligns with the PR objective to resolve the LibXMLParser::xmlCleanupParser crash mentioned in issue #14.

Consider adding a comment explaining why this parser change was made, to provide context for future maintenance:

            exclude: ["svgnative/src/win",
                      "svgnative/src/xml/ExpatXMLParser.cpp",
+                     // Using RapidXMLParser instead of LibXMLParser to resolve xmlCleanupParser crash (see issue #14)
                      "svgnative/src/xml/LibXMLParser.cpp",
                      "svgnative/src/ports/cairo",
svgnative.podspec (1)

41-41: Consistent parser implementation change in podspec file

The podspec file has been correctly updated to exclude LibXMLParser.cpp instead of RapidXMLParser.cpp, matching the change in Package.swift. This ensures consistency between Swift Package Manager and CocoaPods implementations.

As with Package.swift, consider adding a comment explaining the reason for this change:

  s.exclude_files = ['svg-native-viewer/svgnative/src/xml/ExpatXMLParser.cpp',
+                     # Using RapidXMLParser instead of LibXMLParser to resolve xmlCleanupParser crash (see issue #14)
                     'svg-native-viewer/svgnative/src/xml/LibXMLParser.cpp',
                     'svg-native-viewer/svgnative/src/ports/cairo',
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de560bb and 9e3635c.

📒 Files selected for processing (2)
  • Package.swift (1 hunks)
  • svgnative.podspec (1 hunks)

@Eggers-CGI
Copy link

Eggers-CGI commented Apr 2, 2025

"Awesome! I can confirm that the parser replacement solved my open regression test for multi-threaded SVG loading. The LibXMLParser::xmlCleanupParser issue within the DispatchQueue seems to have been the root cause of the problem, and it's now reliably resolved.

Here's the code snippet I used for testing:
swift

DispatchQueue.global(qos: .userInteractive).async {
    autoreleasepool {
        for _ in 0..<100 {
            let url = svgURLs.randomElement()!
            let _ =  WebImage(url: url)
        }
    }
}

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.

2 participants