You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When repeatedly creating and closing WebMessageChannels, the old IOSWebMessageChannel objects do not seem to get fully disposed (even after GC) . Apparently due to a cyclic reference in IOSWebMessageChannel.
Expected Behavior
Old WebMessageChannels with no reference from within the application should be freed.
On each page load a JavaScript hook (via addJavaScriptHandler) is called that re-creates the WebMessageChannel by calling _createWebMessageChannel(). Simply overriding the variable with a new WebMessageChannel should free the old instance (after GC). But even when closing it manually (by calling _closeWebMessageChannel()) the old instances pile up.
Stacktrace/Logs
Stacktrace/Logs
<Replace this line by pasting your stacktrace or logs here>
Flutter version
v3.24.3
Operating System, Device-specific and/or Tool
iOS 17.2
Plugin version
v6.1.5
Additional information
When tracing back to the point where the IOSWebMessageChannel gets created we end up at IOSWebMessageChannel's _fromMap(). In there the generated IOSWebMessageChannel's _iosPort1 and _iosPort1 get associated with that generated IOSWebMessageChannel itself:
var webMessageChannel =IOSWebMessageChannel(...);
webMessageChannel._iosPort1.webMessageChannel = webMessageChannel;
webMessageChannel._iosPort2.webMessageChannel = webMessageChannel;
Thereby those ports hold a reference to the IOSWebMessageChannel and the IOSWebMessageChannel holds references to them.
On each page load we create a WebMessageChannel and store it's reference in a variable (javaScriptWebMessageChannel).
Even if we explicitly close it and set the variables to null via
the IOSWebMessageChannel (and port) instances keep going up – see attached screenshot of the Flutter Dev Tools Memory Debugger after re-creating the WebMessageChannel 8 times.
Self grab
I'm ready to work on this issue!
The text was updated successfully, but these errors were encountered:
Is there an existing issue for this?
Current Behavior
When repeatedly creating and closing WebMessageChannels, the old IOSWebMessageChannel objects do not seem to get fully disposed (even after GC) . Apparently due to a cyclic reference in IOSWebMessageChannel.
Expected Behavior
Old WebMessageChannels with no reference from within the application should be freed.
Steps with code example to reproduce
Steps with code example to reproduce
On each page load a JavaScript hook (via
addJavaScriptHandler
) is called that re-creates the WebMessageChannel by calling_createWebMessageChannel()
. Simply overriding the variable with a new WebMessageChannel should free the old instance (after GC). But even when closing it manually (by calling_closeWebMessageChannel()
) the old instances pile up.Stacktrace/Logs
Stacktrace/Logs
Flutter version
v3.24.3
Operating System, Device-specific and/or Tool
iOS 17.2
Plugin version
v6.1.5
Additional information
When tracing back to the point where the IOSWebMessageChannel gets created we end up at IOSWebMessageChannel's
_fromMap()
. In there the generated IOSWebMessageChannel's_iosPort1
and_iosPort1
get associated with that generated IOSWebMessageChannel itself:Thereby those ports hold a reference to the IOSWebMessageChannel and the IOSWebMessageChannel holds references to them.
On each page load we create a WebMessageChannel and store it's reference in a variable (
javaScriptWebMessageChannel
).Even if we explicitly close it and set the variables to null via
the IOSWebMessageChannel (and port) instances keep going up – see attached screenshot of the Flutter Dev Tools Memory Debugger after re-creating the WebMessageChannel 8 times.
Self grab
The text was updated successfully, but these errors were encountered: