Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

frameworks-native: Commit

frameworks/native


Commit MetaInfo

Revision87d725793ec559e1f1ad67108a2c4806313e8a26 (tree)
Time2020-05-21 11:16:53
AuthorMatt Moeller <matthew.moeller@kinz...>
CommiterChih-Wei Huang

Log Message

ISurfaceComposer: Workaround for screenshots on intel graphics

Prevent the GraphicBuffer destructor until after the screencap client
has had a chance to consume it.

Change Summary

Incremental Difference

--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -19,6 +19,7 @@
1919
2020 #include <stdint.h>
2121 #include <sys/types.h>
22+#include <thread>
2223
2324 #include <binder/Parcel.h>
2425 #include <binder/IPCThreadState.h>
@@ -631,6 +632,20 @@ status_t BnSurfaceComposer::onTransact(
631632 reply->write(*outBuffer);
632633 reply->writeBool(capturedSecureLayers);
633634 }
635+
636+ // XXX
637+ // When outBuffer goes out of scope, the destructor gets called and on some
638+ // graphics platforms (intel i915) this will actually free the underlying buffer
639+ // containing the screen capture. The guy on the other end of this binder transaction
640+ // will try to open the buffer that has been freed and fail.
641+ //
642+ // The super-hacky workaround here is to delay the destructor call in a thread so
643+ // the binder client can obtain the buffer in question. When the thread timeout expires
644+ // the destructor will get called and clean up the buffer so there is no memory leak.
645+ std::thread([outBuffer]() {
646+ std::this_thread::sleep_for(std::chrono::seconds(1));
647+ }).detach();
648+
634649 return NO_ERROR;
635650 }
636651 case CAPTURE_LAYERS: {
Show on old repository browser