-
Notifications
You must be signed in to change notification settings - Fork 32
Add support for performance.measureUserAgentSpecificMemory()
#208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Since that API is experimental, it is not exposed by You might get away with using an extension / extension type? import 'dart:js_interop';
import 'package:web/web.dart';
extension PerformanceMemory on Performance {
@JS('measureUserAgentSpecificMemory')
external JSFunction? get _measureUserAgentSpecificMemory;
Future<UserAgentSpecificMemory?> measureUserAgentSpecificMemory() {
if (_measureUserAgentSpecificMemory == null) {
return Future<UserAgentSpecificMemory?>.value();
}
return (_measureUserAgentSpecificMemory!.callAsFunction() as JSPromise<UserAgentSpecificMemory>).toDart;
}
}
@JS()
extension type UserAgentSpecificMemory._(JSObject _) implements JSObject {
external int get bytes;
external JSArray<UserAgentSpecificMemoryBreakdownElement> get breakdown;
}
@JS()
extension type UserAgentSpecificMemoryBreakdownElement._(JSObject _) implements JSObject {
external JSArray<UserAgentSpecificMemoryBreakdownAttributionElement> get attribution;
external int get bytes;
external JSArray<JSString> get types;
}
@JS()
extension type UserAgentSpecificMemoryBreakdownAttributionElement._(JSObject _) implements JSObject {
external UserAgentSpecificMemoryBreakdownAttributionContainerElement? get container;
external String get scope;
external String get url;
}
@JS()
extension type UserAgentSpecificMemoryBreakdownAttributionContainerElement._(JSObject _) implements JSObject {
external String get id;
external String get url;
} Although, when I inspect if the method is defined, on my Chrome 122.0.6261.128 instance , I don't think there is a different API for it though. |
This may get added back as part of #209. It's on track to be a standard, but it's marked |
Since we still exclude |
In the DevTools flutter web app, we'd like to periodically check our memory usage to take action and release resources before OOMing (flutter/devtools#7002). To do this, I was looking at using the browser memory API:
https://developer.mozilla.org/en-US/docs/Web/API/Performance/measureUserAgentSpecificMemory
This doesn't appear to be available from the Performance API in package:web:
web/lib/src/dom/hr_time.dart
Line 39 in 2f13cd5
Are there plans to support this? Is there a better way we should be checking the total memory usage for the web app?
The text was updated successfully, but these errors were encountered: