[Spice-devel] streaming assertion

Jonathon Jongsma jjongsma at redhat.com
Tue May 20 13:19:00 PDT 2014


I've been investigating bug 1086820 that results in a failed assertion in spice-server (causing the guest to exit) related to mjpeg streaming. This is the debug output when we hit this issue:

(/usr/bin/qemu-kvm:3165): Spice-ERROR **: mjpeg_encoder.c:627:mjpeg_encoder_adjust_params_to_bit_rate: assertion `rate_control->num_recent_enc_frames' failed

Here's what I know so far:
- mjpeg_encoder_adjust_params_to_bit_rate() is actually called quite often with num_recent_enc_frames set to 0. But usually when num_recent_enc_frames is 0, last_enc_size is also 0, so we bail out of the function early and print a debug message "missing sample size".
- Under some circumstances, mjpeg_encoder_reset_quality() gets called with quality_id set to the same quality id that we're currently using. The code anticipates this possibility and has a test for it: if the new quality ID is the same as the old, we don't clear last_enc_size. But we do still clear num_recent_enc_frames. This is where we become susceptible to the assert mentioned above.  Now last_enc_size is non-zero, but num_recent_enc_frames is 0.

It seems to me that these two values should probably be cleared together. But I'm not sure whether it is more correct to clear them or *not* clear them when new quality == old quality.

I've tested with both of the following alternative patches, and they both seem to work properly and avoid the assert. I'd appreciate input from somebody with more experience with spice-server streaming code.

Jonathon

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1086820
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-assertion-in-mjpeg_encoder_adjust_params_to_bit_rate-1
Type: text/x-patch
Size: 1216 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20140520/599a8e0c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-assertion-in-mjpeg_encoder_adjust_params_to_bit_rate-2
Type: text/x-patch
Size: 1069 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20140520/599a8e0c/attachment-0001.bin>


More information about the Spice-devel mailing list