Send CloseableRef leaks to Flipper plugin (#455)

Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/455

Only logging to the console for now, but it's a good start.

Reviewed By: oprisnik

Differential Revision: D15535820

fbshipit-source-id: 8531ec5ef681d01b2428a1f016b2a1d9f1589a34
This commit is contained in:
Pascal Hartig
2019-05-31 16:55:24 -07:00
committed by Facebook Github Bot
parent 7dc3525846
commit faf19452eb
3 changed files with 62 additions and 28 deletions

View File

@@ -67,3 +67,8 @@ export type ImageEvent = {
export type FrescoDebugOverlayEvent = {|
enabled: boolean,
|};
export type AndroidCloseableReferenceLeakEvent = {|
identityHashCode: string,
className: string,
|};

View File

@@ -12,6 +12,7 @@ import type {
ImagesListResponse,
ImageEvent,
FrescoDebugOverlayEvent,
AndroidCloseableReferenceLeakEvent,
CacheInfo,
} from './api.js';
import type {ImagesMap} from './ImagePool.js';
@@ -225,6 +226,13 @@ export default class extends FlipperPlugin<PluginState, *, PersistedState> {
this.setState({isDebugOverlayEnabled: event.enabled});
},
);
this.client.subscribe(
'closeable_reference_leak_event',
(event: AndroidCloseableReferenceLeakEvent) => {
// TODO(T45065440): Temporary log, to be turned into counter.
console.warn('CloseableReference leak detected:', event);
},
);
this.imagePool = new ImagePool(this.getImage, (images: ImagesMap) =>
this.props.setPersistedState({imagesMap: images}),
);