Skip to content

Commit 1f3fc1e

Browse files
authored
Fix memory leak when using screensharing on macOS (#133)
1 parent e69627c commit 1f3fc1e

File tree

7 files changed

+197
-86
lines changed

7 files changed

+197
-86
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ All user visible changes to this project will be documented in this file. This p
2525
### Fixed
2626

2727
- Video renderer stretching a picture after rotation. ([#124])
28+
- Screen sharing leaking memory on [macOS]. ([#133])
2829

2930
[#117]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/117
3031
[#119]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/119
3132
[#120]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/120
3233
[#123]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/123
3334
[#124]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/124
3435
[#125]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/125
36+
[#133]: https://github.com/instrumentisto/medea-flutter-webrtc/pull/133
3537
[116.0.5845.110]: https://github.com/instrumentisto/libwebrtc-bin/releases/tag/116.0.5845.110
3638

3739

Cargo.lock

Lines changed: 59 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#pragma once
2+
3+
#if __APPLE__
4+
5+
#include "modules/desktop_capture/mouse_cursor_monitor.h"
6+
7+
namespace bridge {
8+
9+
// Captures mouse shape and position.
10+
// Wraps `webrtc::MouseCursorMonitor` wrapping `Capture` calls with @autorelease
11+
// block to prevent memory leaking.
12+
class MouseCursorMonitorMac : public webrtc::MouseCursorMonitor {
13+
public:
14+
// Creates a new `MouseCursorMonitorMac`.
15+
MouseCursorMonitorMac(
16+
std::unique_ptr<webrtc::MouseCursorMonitor> mouse_monitor);
17+
18+
// Initializes the monitor with the `callback`, which must remain valid until
19+
// the capturer is destroyed.
20+
virtual void Init(Callback* callback, Mode mode) override;
21+
22+
// Captures the current cursor shape and position
23+
void Capture() override;
24+
25+
private:
26+
// Inner `MouseCursorMonitor` that this `MouseCursorMonitorMac` delegates
27+
// calls to.
28+
std::unique_ptr<webrtc::MouseCursorMonitor> mouse_monitor_;
29+
};
30+
31+
} // namespace bridge
32+
33+
#endif

0 commit comments

Comments
 (0)