Refactor ScreenCaptureListenerWrapper to guarantee callback delivery
The previous implementation of ScreenCaptureListenerWrapper used a weak reference to hold the Java consumer object. This created a race where the Java consumer could be garbage collected before the native onScreenCaptureCompleted() callback was invoked. In that case the screenshot result will be sliently dropped. This change uses a strong global reference to the Java consumer object, to ensure the consumer remains alive until the native callback is invoked. The strong reference will be deleted immediately after the callback is fired, as the listener is a one-shot mechanism. Test: presubmit and locally tested screenshot functions. Test: adding logs and see if the global reference deletion is called after screenshot finishes. Bug: 441019220 Flag: EXEMPT BUGFIX Change-Id: I8e907384b915c30a7b9c1927b1cd517da26561e3
Loading
Please register or sign in to comment