Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidInput for Camera::start with a valid config, only in release mode #18

Open
joelgallant opened this issue Sep 25, 2018 · 6 comments

Comments

@joelgallant
Copy link
Contributor

joelgallant commented Sep 25, 2018

When running a --release build (no non-standard options), Camera::start, which functions correctly with debug mode, throws the error: Io(Os { code: 22, kind: InvalidInput, message: "Invalid argument" }). I cannot adjust the options correctly to get it to not do this, and the options I select do show up when doing camera.resolution, etc.

As far as I can tell, it derives from here:
https://github.com/loyd/rscam/blob/5e7a429fe1faed82925832c5ea5d3c9dadb6b239/src/v4l2.rs#L87-90

This led me down the path of enabling the no_wrapper feature, which did work in release mode, but changed the available formats, frame rates, etc. that it would allow me to use. I assume that differences between release and debug are not intentional, so I'd rather avoid that road.

It's worth mentioning that I am cross compiling for armv7-unknown-linux-gnueabihf.

I'm going to look in to this issue since it does matter to me for my project, but if you have any ideas I'd love any tips you might have?

@joelgallant
Copy link
Contributor Author

joelgallant commented Sep 25, 2018

On second look, I'm wrong about where the error is coming from - I believe it's alloc_buffers and mmap.

Specifically, v4l2_mmap returns usize::MAX and triggers the check_io!. The error is last_os_error, which is incorrect in this case as far as I can tell - it reports as InvalidArgument (which probably does make sense, since this is linking to v4l2_mmap, that doesn't report it's error using last_os_error).

@loyd
Copy link
Owner

loyd commented Sep 29, 2018

this is linking to v4l2_mmap, that doesn't report it's error using last_os_error

v4l2_mmap uses errno, according to the documentation

It's worth mentioning that I am cross compiling for armv7-unknown-linux-gnueabihf.

I'll try to reproduce your problem as soon as I get my raspberry back.

@joelgallant
Copy link
Contributor Author

joelgallant commented Sep 29, 2018

I noticed that it does say it sets errno, when printing last_os_error before/after v4l2_mmap, it doesn't change - which doesn't mean it's not working.

@skligys
Copy link

skligys commented Oct 8, 2018

I am seeing a similar error in Camera::start (also cross-compiling to Pi), also only in --release build:

I/O error: Value too large for defined data type (os error 75)

Strangely enough, if I clone rscam's source locally and build it:

[dependencies]
rscam = { path = "vendor/rscam" }

everything works just fine. Was the failure fixed since 0.5.4 release?

@jbolila
Copy link

jbolila commented Dec 16, 2018

Compiling locally on a raspberry pi, also gives an error when compiled with --release.

Comparing both strace output the issue happens on the following call:

ioctl(3, VIDIOC_REQBUFS, {count=2, type=V4L2_BUF_TYPE_VIDEO_CAPTURE, memory=V4L2_MEMORY_MMAP}) = 0 ({count=2})
ioctl(3, VIDIOC_QUERYBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, index=0, memory=V4L2_MEMORY_MMAP, m.offset=0, length=307200, bytesused=0, flags=0x2000 /* V4L2_BUF_FLAG_??? */, ...}) = 0
write(2, "thread '", 8thread ')                 = 8
write(2, "main", 4main)                     = 4
write(2, "' panicked at '", 15' panicked at ')         = 15
write(2, "called `Result::unwrap()` on an "..., 113called `Result::unwrap()` on an `Err` value: Io(Os { code: 22, kind: InvalidInput, message: "Invalid argument" })) = 113
write(2, "', ", 3', )                      = 3

compared with the debug version:

ioctl(3, VIDIOC_REQBUFS, {count=2, type=V4L2_BUF_TYPE_VIDEO_CAPTURE, memory=V4L2_MEMORY_MMAP}) = 0 ({count=2})
ioctl(3, VIDIOC_QUERYBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, index=0, memory=V4L2_MEMORY_MMAP, m.offset=0, length=307200, bytesused=0, flags=0x2000 /* V4L2_BUF_FLAG_??? */, ...}) = 0
mmap2(NULL, 307200, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x76c02000
ioctl(3, VIDIOC_QUERYBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, index=1, memory=V4L2_MEMORY_MMAP, m.offset=0x4b000, length=307200, bytesused=0, flags=0x2000 /* V4L2_BUF_FLAG_??? */, ...}) = 0
mmap2(NULL, 307200, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0) = 0x767b5000
ioctl(3, VIDIOC_QBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, index=0, memory=V4L2_MEMORY_MMAP, m.offset=0, length=307200, bytesused=0, flags=V4L2_BUF_FLAG_MAPPED|V4L2_BUF_FLAG_QUEUED|0x2000, ...}) = 0
ioctl(3, VIDIOC_QBUF, {type=V4L2_BUF_TYPE_VIDEO_CAPTURE, index=1, memory=V4L2_MEMORY_MMAP, m.offset=0x4b000, length=307200, bytesused=0, flags=V4L2_BUF_FLAG_QUEUED|0x2000, ...}) = 0
ioctl(3, VIDIOC_STREAMON, [V4L2_BUF_TYPE_VIDEO_CAPTURE]) = 0

I'm using the latest version (v0.5.4)

@chris-ricketts
Copy link

I've just encountered this cross-compiling to armv7-unknown-linux-gnueabihf as well.
However, in this case the error occurs when built in debug, with --release it works.

This is version 0.5.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants