Repository navigation
fix(replay): Use software canvas for the video encoder on the Android Emulator - #6282
Open
sentry-junior[bot] wants to merge 2 commits into
Open
sentry-junior[bot] wants to merge 2 commits into
sentry-junior[bot] wants to merge 2 commits into
Conversation
… Emulator Co-Authored-By: Roman Zavarnitsyn <roman.zavarnitsyn@sentry.io>
romtsn
marked this pull request as ready for review
October 19, 2026 10:20
romtsn
requested review from
0xadam-brown,
adinauer,
markushi,
romtsn and
runningcode
as code owners
October 19, 2026 10:20
📲 Install BuildsAndroid
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
SimpleVideoEncodernow draws frames withlockCanvas(null)instead oflockHardwareCanvas()when running on the Android Emulator (Build.HARDWAREcontainsgoldfishorranchu), the same way it already does for Xiaomi, Motorola and Spreadtrum/Unisoc devices. The device check moved into an internalshouldUseSoftwareCanvas()function so it can be unit tested.💡 Motivation and Context
With a hardware canvas, hwui creates an EGL window surface on the encoder's input
Surface. The emulator's EGL driver (libEGL_emulation, gfxstreamguest/egl/egl.cpp) dequeues the next buffer up front, at surface init and after everyswapBuffers, and cancels it in~egl_window_surface_t.CCodec::stop()already disconnects the input surface, so whenSurface.release()later destroys the hwui context, the driver cancels a buffer whose queue is gone. That shows up as an intermittent SIGSEGV ineglDestroySurfaceon the RenderThread. A software canvas keeps hwui and EGL off this surface entirely. Drawing one small bitmap per frame on the CPU is cheap.Reordering the teardown in
release()was considered too. It would have to movesurface.release()beforemediaCodec.stop(), not just beforemediaCodec.release(), and it changes behavior on every device. This PR keeps the change scoped to the emulator.eglDestroySurface(libEGL_emulation) whenSimpleVideoEncoderreleases its input surface on the Android emulator #6279💚 How did you test it?
Added
SimpleVideoEncoderCanvasTest, a Robolectric test that covers regular devices, Xiaomi, Motorola, and ranchu/goldfish emulators.ReplayCacheTeststill passes. The reporter offered to try a patched build on the emulator image where the crash happened.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Ask the reporter to verify on
system-images;android-37.1;google_apis_playstore_ps16k;arm64-v8a.via roman.
--
View Junior Session [Sentry]