Merge lp:~albaguirre/mir/screencast-crash-fix into lp:mir
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Daniel van Vugt | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 1404 | ||||
Proposed branch: | lp:~albaguirre/mir/screencast-crash-fix | ||||
Merge into: | lp:mir | ||||
Diff against target: |
135 lines (+38/-36) 1 file modified
src/utils/screencast.cpp (+38/-36) |
||||
To merge this branch: | bzr merge lp:~albaguirre/mir/screencast-crash-fix | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Alexandros Frantzis (community) | Approve | ||
Review via email: mp+206337@code.launchpad.net |
Commit message
Fix crash in android devices by working around a subtle threading bug
Use a dummy thead_local array to push the gl/egl context TLS into a region
where the future wait code does not overwrite it.
Other changes:
- Query the preferred read pixel format/type at setup.
- Write a video file instead of snapshot files; the raw file can then be played as a video with vlc
fixes: lp: #1280086
Description of the change
Fix crash in android devices by working around a subtle threading bug
Use a dummy thead_local array to push the gl/egl context TLS into a region
where the future wait code does not overwrite it.
Other changes:
- Query the preferred read pixel format/type at setup.
- Write a video file instead of snapshot files; the raw file can then be played as a video with vlc
fixes: lp: #1280086
For some unkown reason, on android devices, the EGL context goes bad after waiting on a future in the main thread - the EGL context was made current in the main thread and should remain so.
Possibly a TLS issue with libhybris?
> Remove the use of asyncs to dispatch file writes; no real reason to launch one as the main loop just synchronizes it with a wait anyway.
Actually there is a reason: with an async file write, we can swap the screencast buffer and write to file concurrently, which depending on the actual operation timings and IO blocking, helps improve the capture frame rate (so, iteration_time = max(write_time, swap_time) instead of iteration_time = write_time + swap_time).
Anyway, this is the main point of the workaround, so no point arguing for this to stay :)
Hopefully we can reinstate it when when we fix the core issue.
> std::ofstream videoFile( ss.str( ));
We should use underscores in variable names: http:// unity.ubuntu. com/mir/ cppguide/ index.html# Variable_ Names
> glGetIntegerv( GL_IMPLEMENTATI ON_COLOR_ READ_FORMAT, &format);
GL_IMPLEMENTATI ON_COLOR_ READ_FORMAT is meaningful only in combination with GL_IMPLEMENTATI ON_COLOR_ READ_TYPE (i.e., we can't assume per the standard that GL_IMPLEMENTATI ON_COLOR_ READ_TYPE => GL_UNSIGNED_BYTE, although it's often the case). Since we currently want support for either RGBA8888 or BGRA8888 frames, we should check that GL_IMPLEMENTATI ON_COLOR_ READ_TYPE == GL_UNSIGNED_BYTE and GL_IMPLEMENTATI ON_COLOR_ READ_FORMAT == BGRA and only then return it as valid, otherwise return the guaranteed default RGBA.
Note that when implementing surface snapshots I found that using the GL_IMPLEMENTATI ON_COLOR_ READ_FORMAT/ TYPE was unreliable (e.g., using the returned values failed depending on the underlying buffer type), although the situation was more complex there, involving FBOs backed by textures backed by EGLImages. That's why I used the double glReadPixels scheme, which was also used here.