Skip to content

Fixed multiple memory leaks across components#795

Merged
Vetle444 merged 7 commits intomainfrom
copilot/identify-memory-leaks
Apr 8, 2026
Merged

Fixed multiple memory leaks across components#795
Vetle444 merged 7 commits intomainfrom
copilot/identify-memory-leaks

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

  • Fix CameraSession.cs (iOS): PreviewView.OnTapToFocus event never unsubscribed in StopCameraSession()
  • Fix SearchBarHandler.cs (iOS): Wrong event unsubscribed - SearchButtonClicked handler unsubscribed from CancelButtonClicked instead of SearchButtonClicked
  • Fix SlidableLayout.cs: TapGestureRecognizer.Tapped event never unsubscribed due to missing field reference
  • Fix SegmentedControl.cs: border.SizeChanged event never unsubscribed when items replaced or handler disconnects
  • Update CHANGELOG.md with memory leak fixes

…, SearchBarHandler, and SlidableLayout

Co-authored-by: Vetle444 <35739538+Vetle444@users.noreply.github.com>
Copilot AI changed the title [WIP] Identify possible memory leaks in the application Fix memory leaks from missing event unsubscriptions Feb 27, 2026
@Vetle444 Vetle444 marked this pull request as ready for review April 7, 2026 14:04
Copilot AI review requested due to automatic review settings April 7, 2026 14:04
@Vetle444 Vetle444 changed the title Fix memory leaks from missing event unsubscriptions Fixed multiple memory leaks across components Apr 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses multiple memory-leak vectors across DIPS.Mobile.UI components/handlers by ensuring event subscriptions, timers, animations, and native callbacks are properly cleaned up when views/handlers are disconnected or rebuilt.

Changes:

  • Replaced anonymous event handlers (lambdas/delegates) with named methods to enable reliable unsubscription and prevent captured references.
  • Added missing event unsubscriptions / disposal (e.g., iOS camera preview events, timers, Android native callbacks, gesture recognizers).
  • Improved handler-lifecycle alignment for subscriptions (moving subscribe/unsubscribe to OnHandlerChanged / OnHandlerChanging where appropriate).

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/library/DIPS.Mobile.UI/Components/TabView/iOS/TabView.cs Replaces anonymous tab tap handler with named method and unsubscribes in ClearItems().
src/library/DIPS.Mobile.UI/Components/Slidable/SlidableLayout.cs Stores tap recognizer as a field and unsubscribes on handler disconnect.
src/library/DIPS.Mobile.UI/Components/Shell/Shell.cs Unsubscribes Navigated on handler disconnect to avoid lingering references.
src/library/DIPS.Mobile.UI/Components/Searching/SearchPage.cs Moves TextChanged subscription to handler lifecycle and unsubscribes on handler disconnect.
src/library/DIPS.Mobile.UI/Components/Pickers/SegmentedControl/SegmentedControl.cs Replaces anonymous SizeChanged handler with named method.
src/library/DIPS.Mobile.UI/Components/Pickers/ScrollPicker/Android/ScrollPickerHandler.cs Disposes ScrollPickerViewModel on handler disconnect.
src/library/DIPS.Mobile.UI/Components/Pickers/NullableDatePickerShared/BaseNullableDatePicker.cs Unsubscribes switch Toggled on handler disconnect.
src/library/DIPS.Mobile.UI/Components/Pickers/ItemPicker/ItemPicker.cs Unsubscribes CollectionChanged from old ItemsSource before subscribing to new.
src/library/DIPS.Mobile.UI/Components/Pickers/DatePickerShared/iOS/BaseDatePickerHandler.cs Adds missing ValueChanged unsubscription on disconnect.
src/library/DIPS.Mobile.UI/Components/Navigation/FloatingNavigationButton/FloatingNavigationButtonService.cs Clears static FAB reference on Remove() to allow GC.
src/library/DIPS.Mobile.UI/Components/Navigation/FloatingNavigationButton/Android/FloatingNavigationButtonHandler.cs Replaces anonymous click handler with named method and prevents duplicate subscriptions.
src/library/DIPS.Mobile.UI/Components/Loading/StateView/StateView.cs Tracks previous StateViewModel to unsubscribe old OnStateChanged.
src/library/DIPS.Mobile.UI/Components/Loading/Skeleton/SkeletonView.cs Stops animation when handler disconnects to avoid repeat callbacks retaining the view.
src/library/DIPS.Mobile.UI/Components/BottomSheets/Android/BottomSheetHandler.cs Stores/removes native callback/listener instances to prevent Java-side GC roots.
src/library/DIPS.Mobile.UI/Components/Alerting/SystemMessage/SystemMessage.cs Disposes the timer in Dispose().
src/library/DIPS.Mobile.UI/API/Camera/Shared/iOS/CameraSession.cs Unsubscribes PreviewView.OnTapToFocus when stopping session.
src/library/DIPS.Mobile.UI/API/Camera/Gallery/BottomSheet/GalleryBottomSheet.cs Replaces anonymous SizeChanged handlers with named methods and unsubscribes appropriately.
CHANGELOG.md Adds a patch release entry documenting leak fixes.
build/bootstrapper/bootstrapper.sh Fixes Azure CLI presence check to silence stderr.

@Vetle444 Vetle444 enabled auto-merge (squash) April 8, 2026 10:02
…e replaced or handler disconnects

Agent-Logs-Url: https://github.com/DIPSAS/DIPS.Mobile.UI/sessions/0ff7e0eb-4f90-4086-82a6-b6528e2a7d38

Co-authored-by: Vetle444 <35739538+Vetle444@users.noreply.github.com>
auto-merge was automatically disabled April 8, 2026 10:04

Head branch was pushed to by a user without write access

Copilot stopped work on behalf of Vetle444 due to an error April 8, 2026 10:05
Copilot AI requested a review from Vetle444 April 8, 2026 10:05
@Vetle444 Vetle444 enabled auto-merge (squash) April 8, 2026 10:07
@Vetle444 Vetle444 merged commit 7a1d09a into main Apr 8, 2026
1 check passed
@Vetle444 Vetle444 deleted the copilot/identify-memory-leaks branch April 8, 2026 10:16
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.

5 participants