fix: memory leak in prelaunch splash#746
fix: memory leak in prelaunch splash#746misaka18931 wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
The PrelaunchSplash handler in ShellHandler does not properly unlock the wlr_buffer it received when it decides to skip the splash. Coincidentally, WindowConfigStore decided to lock the buffer again while waiting for the DConfig object to initialize, which was unnecessary, since the buffer would have been locked by wlr_buffer_try_from_resource, and erroneous as it failed to unlock it after. These issues combined will cause all icon buffers that are displayed, plus some which fails to do so, to leak memory, until treeland terminates.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: misaka18931 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes a memory leak in the prelaunch splash flow by ensuring icon buffers are always unlocked when the splash is skipped and by removing an unnecessary lock during configuration loading, simplifying the control flow between ShellHandler and WindowConfigStore. Sequence diagram for updated prelaunch splash handlingsequenceDiagram
actor Client
participant ShellHandler
participant WindowConfigStore
participant IconBuffer as iconBuffer
Client->>ShellHandler: handlePrelaunchSplashRequested(appId, iconBuffer)
alt prelaunch_disabled_or_invalid_or_duplicate
ShellHandler->>IconBuffer: unlock()
ShellHandler->>ShellHandler: m_pendingPrelaunchAppIds.remove(appId)
ShellHandler-->>Client: return
else prelaunch_enabled_and_valid
ShellHandler->>ShellHandler: m_pendingPrelaunchAppIds.insert(appId)
ShellHandler->>WindowConfigStore: withSplashConfigFor(appId, context, callback, skipCallback)
alt no_config_or_dconfig_disabled_or_invalid_theme
WindowConfigStore->>ShellHandler: skipCallback()
ShellHandler->>IconBuffer: unlock()
ShellHandler->>ShellHandler: m_pendingPrelaunchAppIds.remove(appId)
else config_ready
WindowConfigStore-->>ShellHandler: callback(appId, dconfigPath, darkPalette, lightPalette, splashThemeType)
ShellHandler->>ShellHandler: createPrelaunchSplash(appId, ...)
end
end
Updated class diagram for ShellHandler and WindowConfigStore interactionclassDiagram
class ShellHandler {
- QList~SurfaceWrapper*~ m_prelaunchWrappers
- QSet~QString~ m_pendingPrelaunchAppIds
- WindowConfigStore* m_windowConfigStore
- AppIdResolverManager* m_appIdResolverManager
+ void handlePrelaunchSplashRequested(QString appId, qw_buffer* iconBuffer)
+ void createPrelaunchSplash(QString appId, QString dconfigPath, QString darkPalette, QString lightPalette, qlonglong splashThemeType)
}
class WindowConfigStore {
+ void withSplashConfigFor(QString appId,
QObject* context,
std::function~void(QString appId, QString dconfigPath, QString darkPalette, QString lightPalette, qlonglong splashThemeType)~ callback,
std::function~void()~ skipCallback) const
- AppConfig* configForApp(QString appId) const
}
class iconBuffer
ShellHandler --> WindowConfigStore : uses
ShellHandler --> iconBuffer : manages_lock_unlock
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a memory leak in the prelaunch splash handling mechanism where icon buffers were not being properly managed. The issue was caused by unnecessary buffer locking in the WindowConfigStore while waiting for DConfig initialization, combined with missing unlock calls when the splash is skipped.
Changes:
- Removed the
waitCallbackparameter fromwithSplashConfigFormethod that was unnecessarily locking buffers - Restructured early return conditions in
handlePrelaunchSplashRequestedto ensure the unlock callback is always called when skipping splash creation - Removed unused
#include <utility>header
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/core/windowconfigstore.h | Removed waitCallback parameter from withSplashConfigFor method signature |
| src/core/windowconfigstore.cpp | Removed waitCallback implementation, assertions, and the redundant buffer lock call |
| src/core/shellhandler.cpp | Restructured logic to call skipSplash() (which unlocks buffer) in all early-return paths; removed unused header |
The PrelaunchSplash handler in ShellHandler does not properly unlock the wlr_buffer it received when it decides to skip the splash. Coincidentally, WindowConfigStore decided to lock the buffer again while waiting for the DConfig object to initialize, which was unnecessary, since the buffer would have been locked by wlr_buffer_try_from_resource, and erroneous as it failed to unlock it after.
These issues combined will cause all icon buffers that are displayed, plus some which fails to do so, to leak memory, until treeland terminates.
Summary by Sourcery
Fix memory leaks and unnecessary buffer locking in the prelaunch splash handling flow.
Bug Fixes:
Enhancements: