I have an app where we want to stream video frames locally from one device to another. We were initially using Multipeer, but wanted to force the user to have to be using infrastructure wifi rather than something like p2p BT.
Using Network.framework, I start a udp NWListener and send the host/port to the client which then connects. This all works well. On the app we compress the frames, send them to the other device, and decompress them on the other end. This all works fine except there are sometimes periods of freeze (oddly when the camera is trying to focus). There are no explicit errors from the framework, but we are getting this in the console during the freeze:
Although we don't get an explicit error from Network.framework, I'm assuming that the message size is too big. I decided to just create an empty project and attempt to send one (uncompressed) frame across. I set it up just like in the WWDC 2018 video using bonjour and udp instead of host port and it got me:
So I guess my question is, in my first error is this a problem with the messages being too long? It seems like in general my message sizes are short enough but the occasional spike is causing a decent freeze, here is an output of printing data.count:
And for the second error in my test project, I was wondering why it is explicit and different. Perhaps because bonjour/udp instead of hostname/port/udp?
Finally, is there demonstration or something I could see that would help me learn how to split up these larger messages with Network.framework over udp? WWDC 2018 has a demo of doing exactly what I want to do, but they gloss over the splitting of frames parts and there's no source code that I could find. Thank you in advance!
Using Network.framework, I start a udp NWListener and send the host/port to the client which then connects. This all works well. On the app we compress the frames, send them to the other device, and decompress them on the other end. This all works fine except there are sometimes periods of freeze (oddly when the camera is trying to focus). There are no explicit errors from the framework, but we are getting this in the console during the freeze:
Code Block 2021-05-19 20:04:57.870871-0400 App Name[17116:5431473] [] nw_protocol_ipv4_frame_output_finalizer [C3:2] Not enough bytes to fragment 70806
Although we don't get an explicit error from Network.framework, I'm assuming that the message size is too big. I decided to just create an empty project and attempt to send one (uncompressed) frame across. I set it up just like in the WWDC 2018 video using bonjour and udp instead of host port and it got me:
Code Block 2021-05-20 15:42:59.656575-0400 NetworkTest[65379:1172081] [connection] nw_flow_prepare_output_frames [C1.2.1 fe80::9:9e05:f383:58a0%en10.52624@en10 ready socket-flow (satisfied (Path is satisfied), interface: en10, expensive)] Data won't fit in frame (9216 < 84272) 2021-05-20 15:42:59.656930-0400 NetworkTest[65379:1172081] [connection] nw_write_request_report [C1] Send failed with error "Message too long" 2021-05-20 15:42:59.657056-0400 NetworkTest[65379:1172081] [connection] nw_flow_prepare_output_frames [C1.2.1 fe80::9:9e05:f383:58a0%en10.52624@en10 ready socket-flow (satisfied (Path is satisfied), interface: en10, expensive)] Failed to use 1 frames, marking as failed Failed to send data with error The operation couldn’t be completed. (Network.NWError error 0.)
So I guess my question is, in my first error is this a problem with the messages being too long? It seems like in general my message sizes are short enough but the occasional spike is causing a decent freeze, here is an output of printing data.count:
Code Block 22713 23313 23236 22278 22545 22342 22920 21996 70798 2021-05-19 20:04:57.870871-0400 Encore Artist Dev[17116:5431473] [] nw_protocol_ipv4_frame_output_finalizer [C3:2] Not enough bytes to fragment 70806
And for the second error in my test project, I was wondering why it is explicit and different. Perhaps because bonjour/udp instead of hostname/port/udp?
Finally, is there demonstration or something I could see that would help me learn how to split up these larger messages with Network.framework over udp? WWDC 2018 has a demo of doing exactly what I want to do, but they gloss over the splitting of frames parts and there's no source code that I could find. Thank you in advance!