Skip to content

Commit dd3679b

Browse files
committed
[FIX] mail: fix retained memory in discuss call tests
Before this commit, discuss call HOOT tests retained the window object after test ended. Retained memory was about 2.5Mb-4Mb per test. An earlier PR [1] fixed a similar issue from a `const` object being used in field default value. This was a problem because JS models internal code is keeping a reference to this object, and since HOOT suite test reuses the same window object, the window of each test were retained. The PR [1] fixed the issue by not setting object as default value of the field. Note that the default value and its presence in internal code of JS models happened for all tests that use `@mail` static files. That means this PR `[1]` fixed a retained memory for all `@mail` and related tests. While this fixed many tests, we still observed this retained memory on all discuss call tests. This happens because while the default value no longer uses this shared object, the computed value still does. Therefore call tests were sharing the const and thus retaining the window object. Note that the computed method is implicitly lazy, so this is only invoked in code that actually uses this `iceServers` field, hence why only discuss call tests were still affected by the issue. This commit fixes the issue by replacing the DEFAULT_ICE_SERVERS object by GET_DEFAULT_ICE_SERVERS function. This ensures each test use a different object, thus preventing retaining the window object after test has ended. [1]: odoo#204521 closes odoo#215208 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
1 parent 504ce79 commit dd3679b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

addons/mail/static/src/discuss/call/common/rtc_service.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ const CAMERA_CONFIG = {
5454
width: 1280,
5555
};
5656
const IS_CLIENT_RTC_COMPATIBLE = Boolean(window.RTCPeerConnection && window.MediaStream);
57-
const DEFAULT_ICE_SERVERS = [
58-
{ urls: ["stun:stun1.l.google.com:19302", "stun:stun2.l.google.com:19302"] },
59-
];
57+
function GET_DEFAULT_ICE_SERVERS() {
58+
return [{ urls: ["stun:stun1.l.google.com:19302", "stun:stun2.l.google.com:19302"] }];
59+
}
6060

6161
/**
6262
* @param {Array<RTCIceServer>} iceServers
@@ -213,7 +213,7 @@ export class Rtc extends Record {
213213
/** @type {{urls: string[]}[]} */
214214
iceServers = Record.attr(undefined, {
215215
compute() {
216-
return this.iceServers ? this.iceServers : DEFAULT_ICE_SERVERS;
216+
return this.iceServers ? this.iceServers : GET_DEFAULT_ICE_SERVERS();
217217
},
218218
});
219219
selfSession = Record.one("RtcSession");

0 commit comments

Comments
 (0)