Hello, everyone. Welcome to APM conference 2021. And in this session, we'll be talking about building iOS device form from scratch with David Halkowski. And without further delay, I'll hand it over to you, David. All right, thank you for the introduction. As you just said, I will be talking about building an iOS device farm. And before I get into it, I just wanted to give some thanks to some of the people that made this possible, which is team mobile who originally let me make this an open source project. And some of the earlier incantations of this lambda test who is actually currently a sponsor of this project and is using it in their products and they will be releasing it soon or it's part of it right now I'm not exactly sure. And also, I want to thank Daniel Paulus for being very cooperative with sharing information and also thankful for his software that he's created that is actually being used by the software that I have made. And the first thing I would like to do actually is to, you know, show the demo of actually what has been created so you have an idea as I'm presenting the different portions of it of, you know, what exactly has been done. So without further ado, I will show the demo here. So hold on one moment. So what you see here is actually this on the upper right is a live feed of actually four phones that are connected to the system. And on the left here is like what you would see when you log into the system to be able to control some phones. So I'm just going to quickly go through here and you know select a couple phones, and you can select a phone you see a video feed of the phone. You can interact with it swiping back and forth. You can click elements, you know as if you're actually interacting with the real phone in person, and you can see it's a very quick, the video of the live phone is matching up almost exactly with what I'm doing on the phone. I want to demonstrate that you can see each different phone and interact with in the same way even though these are all different types of phones. And also I wanted to demonstrate that you can type into the phone using a keyboard. So you can see you can type smoothly and you know effectively do manual test remotely on the phone without having to actually have an in person. So that's about it for the demo. So I'm going to move on. First, a little bit about my background. I actually don't have any extensive background and working with Apple devices or Apple software. My only background in it was actually some number of years ago I was actually Apple phone tech support for Apple products which included like Apple PCs and phones at that time which is mainly PCs. You know, it is kind of interesting that I ended up working with Apple products but I do have an extensive background is developing full systems enterprise systems. I kind of specialize in enterprise content management for what I've done. I worked with a great number of different languages over the years, which has enabled made a lot easier to be able to develop something from scratch that does end up using a lot of these things and you know looking at reference code. And some of the project background as I mentioned, originally this was created. Well, originally some software was created for STF STF is an open source device farm for mainly Android devices. And when I was at T mobile they actually asked me, you know, could you make something that could you alter STF and make it also support iOS devices. So that actually ended up creating a open source project called STF iOS support, which did that. And that took around a year to do on and off and various incantations and a lot of this research that I'm going to be presenting about actually was a part of that. And what I found was that T mobile, I was somewhat restricted by they didn't want to build anything with scratch they wanted to modify the existing STF, which is mainly in no JS, and that ended up being somewhat problematic because it's it's somewhat legacy at this point. And so in the end, you know, I found that at T mobile, it was able to work somewhat, but not quite as much as I wanted so actually eventually, you know I was working through a consulting company at T mobile. And when I was able, when I left there, I decided to actually rewrite everything from scratch, fresh, without using STF to be able to solve a lot of the architectural problems and security issues. So that is what actually, you know, kind of triggered this whole thing is, I said, Hey, I actually want to continue working with this and actually make it even better. And, you know, that so the demo you saw is the result of that work. And I've actually sold the, the currently created product back to T mobile, which is interesting after leaving there. And there are two main clients, the one of them wishes to not be named. And the other one as I said is lambda test. And to start out with discussing like the different types of things that go into making a full device farm. You kind of think about the requirements of like what do you need for device what is a device farm. And generally what you think about is, you know, the video display you saw you want to be able to interact with it like touchscreen taps swipe so on and so forth entering text.  So, you know, for apps, that would be XC test, what drivers in Appium scripts for mobile apps would mainly be Selenium, but you can also use Appium as well to control your mobile apps. And then you also want to be able to monitor, you know, those tests to see what are the memory usage of those tests what are the CPU usage so on and so forth.  When someone has a bad network connection, what the, you know, battery usage is of like how much drain your apps are causing on the device. You may want to be able to like record video of like certain test runs or failures so that people can see like when an automated test fails what's going on. And I'm not going to go through all these because there's a lot of them. And I want to move on with discussing some of the creation of these features. So, in those idea of the requirements, the first question is what already exists, and what can be built on in order to create those features. And to interact with Apple devices that's that's the main thing is like how do you actually automate Apple devices at the low level. And the main thing that's been created is a thing called a live by mobile device which is an open source implementation of Apple software that interacts from the PC to the phones. These are the main features. It's quite capable but some things it does not have and it's also quite complex to understand how it works and how to integrate into your projects. It is actually a re-implementation of what's called the mobile device framework which is a private Apple framework that was made by Apple and they, reverse engineer and lower like just dump the binaries of it and see what different calls it has and that's generally what all these different things are doing is they're they're re-implementing the calls and mobile device framework already has. There's also WebDriver agent which is a, it's an XC test that runs on the phone, but it's long running and provides an API that you can make calls into it so instead of like making an XC test with manual actions, it basically just waits for you to send it commands and then executes those XC test commands. And then there's another thing called iOS deploy. iOS deploy is an open source software that actually makes calls to the private mobile device framework to mainly install apps on phone. One of the new things that we're creating the process of doing all this is go-iOS which is by Daniel Paul as he created it and I believe has discussed some of that. And ios iof which is my own implementation of various calls on top of the mobile device framework, which only runs on macOS. So in the first consideration is like how do you actually detect devices that are plugged into into a machine in order to activate them and show them on a farm. So like using launch agent it's an Apple feature to like activate software it's sort of like system D but for macOS. So it activates different services. And there is some limited features to activate some software when you plug in a USB device, but it doesn't work as you'd expect. It's not a venture for like when you plug in a device and then remove it. It's basically when a device is present it repeatedly tries to do something. So it doesn't really work for the purposes of this. Another option would be like polling so you could just you know run any software that gets a list of connected Apple devices and then use that to repeatedly pull it and then like watch when one appears or disappears. That's obviously not a very good solution. The next option that I tried was using a USB device driver. And this is actually works decently well. Because you just take like the basic stock macOS USB device driver code, and you make it not do anything except for sending notice to some software so basically like it just pretends to be a driver for the device. So that you can get the notice of knowing when the device is plugged or unplugged. And this was actually being used in some of the earlier incantations of this, then there's the you know the Apple mobile device framework, which is what I was using for a while. And it was one of my own implementation iOS if that uses that to get notices from the official, you know, private framework by Apple. Then live on mobile device also has the ability to do this. You can like look at their implementations of listening devices and you can sort of make an adventure of everything I haven't actually done this, because it's inconvenient to do as also go to us by data policy added a feature. That matches my iOS iPhone implementation which is basically just, you know, you run the command and it just says when the device has been connected or disconnected. The next thing to consider is like how do you actually so display of the video on a phone on a computer and you know through the web. And one method would be screenshots. Unfortunately, the way screenshots work through the Apple tooling. Actually, I'll get into that next slide and this is just the overview. So there's screenshots. You know you can use like an HDMI dongle so like Apple has their own dongle you can plug in that has an HTML and then you use like a HDMI capture device after that. And then like DGG these kinds of things in order to get video. There's AV foundation, which is Apple's framework for you know streaming AV stuff, and it has the ability to get at that video of a plugged into device. And FFM Pag has an implementation that uses AV foundation that you can use. And once again, Daniel Paul sorts some software that also interacts with this AV foundation method. There's a replay kit, which is a, it's called an extension on iOS. And you can use replay kit to then stream video through like RTMP or JPEGs or something else. And then there's also WebDriver agent so XC tests that run on the phone. There are private XC test calls that let you get take an image from the full screen. So WebDriver agent, which was originally created by Facebook but is now in by Appium and they're the maintainers of it has an ability to get a streaming MPM JPEG of and basically what it does is it repeatedly takes screenshots, but it does it in a way different from the official Apple ways. So it's slightly better in some ways. And I'll discuss a few of these in a little bit more detail, which is like the screenshots the problem with those is that they're their PNG and their full resolution. So it can be multiple megabytes in size just for a single image, and the speed at which you can actually get them is only around two frames per second at the maximum, which is not very good for, you know, interactivity or the way the way looks the way it feels. And unfortunately Apple does not provide any way, you know, through their, their basically API through a USB connected device to get a lower resolution or to get JPEGs to the PNGs. And as I said, like there's the HDMI dongle method and picture here are some devices, like this one in the top middle is actually a full computer that actually does not work in the same way as an official Apple dongle. It uses a different streaming method but it's just interesting to see that, like, there's different ways to do it. The dongles on the top right is actually just like a splutter so that you could power it as well as use another dongle behind that. The one on the top left has like network as well as HDMI, as well as USB. And then if you did this, the problem with this is if you get a stream of video like it's encoded in HD64 from a capture device, you would then need to reencode it into JPEGs. So like in the bottom left is like a Jetson Nano which is capable of simultaneously decoding like for HD64 streams and then reencoding into JPEGs that can be used. Or you could use something that's like a Pi array, which is basically what you see in the bottom right. The other method is would be using like AV foundation. And basically, so if you open QuickTime on a macOS computer, you can actually get a stream of the USB connected iPhone and see it by selecting the device from there. It actually shows up. So that's why here it shows as AV foundation slash QuickTime. And that's also why the software that Daniel Paul has made is called QuickTime Video Hack because he basically reimplemented what QuickTime is doing in order to activate the video. And AV foundation can also do that by itself without QuickTime. So it's sort of disingenuous because like it's actually AV foundation QuickTime just happens to use that. So Apple actually sort of documented how this works by in one of their conventions they said, oh, you send this basically like act secret activation command that's not document anywhere else except for the conference. And then it like activates the video, and myself as well as Daniel have both reverse engineers and see like what does that command do behind the scenes and it sends like a special control packet. The problems with this is, is Apple just sort of threw it together they actually use it for their presentations of devices like when you see them presenting at conferences about a device, they're using this feature. And you can tell that because when you use this feature, the stream from the phone is fake and they fake out the top bar. They show full battery charge no matter what the actual charges of the device. Because you know they don't want to show a conference with you know oh it doesn't have full battery charge. So if you use this method you can't tell the, you know, in the bar the actual charge of the device. It also shows the specific time because Apple always has this weird thing where they like any presented device has a specific time of release or some nonsense, like, so it does some strange things but the way this actually works is it. The phone encodes in an optimized way to H.264 and then sends that raw H.264 they're called H.264 Nalus the Nalus are each name was like a chunk of video data. So you can then process those that H.264 stream and turn it into JPEGs or something else. And that's one of the issues with this is that it's not scalable, because if you have like 10 devices connected to one machine that's providing this devices to a farm. Then you would have to decode 10 simultaneous H.264 streams and turn them into JPEGs, or potentially you could just stream the entire video stream out to the user. But then they would need to be able to decode those H.264 streams in their browser which some users may or may not be able to do. The other method is a replay kit. So Apple provides this extension, you know as I said that lets you get at the, let's say write an extension to the phone that can run across the whole system and then it basically receives the video data and you can do whatever you want with it. The issues with this is that their examples are very bare bones and don't really do very much and the open source examples of this that there are open source examples, but a lot of them don't work correctly if you try to use them they're very flaky, or they're very hard to integrate. And the issue with making your own version of this is that there's a very strict 40 megabyte memory usage for in this extension. So if you ever go over that 40 megabyte amount it just arbitrarily kills your extension and it's very hard to debug that. So you have to be very careful with how much memory use when you're doing this. And also, like, you would expect that you could use like system logging to diagnose you know if you just add log statements in the middle of your code to see like what's going on. Nope, that doesn't work. It sometimes it works, but most of the time it does not just throws your logs on the trash because it basically treats the extension is like privileged code in the system and it doesn't do very much. And you can sometimes connect Xcode to it to like breakpoint in the middle but the problem is it's constantly receiving frames from the system. And if you add a breakpoint in like are pausing and trying to see what's going on it's it starts freaking out and it basically crashes. So it's very hard to debug this kind of stuff. The examples of this that exist that I initially tried we're using RTMP video streaming, which actually works terribly. I don't I mean, in some instances maybe RTMP can be great, but I can tell you that quickly streaming things with a 40 megabyte usage in an optimal way and setting up the whole procedural stuff just displayed in the browser is very complex. In the end I just chucked it and I said, No, this is not worth it. It's too hard to do the latency was bad. It's much, much, much faster much. The latency is much lower to just encode to JPEGs. So this is actually what I'm doing in the current implementation is I received the video data and I quickly encoded using hardware compression on the phones and then I send those JPEGs out. So the machine like Mac OS machine or Linux machine now that the phone is connected to does not have to handle any encoding or decoding. And that lets it be far more scalable so you can connect many devices without having to worry about, you know, your host machine getting bogged down. The next thing to consider is like, you know, after you have videos working is how do you actually emulate touches on the devices. So, you know, that's taps, long taps. It was just the last things you could see here. And so there's different options here and I'll discuss some of these a little bit. So, for tap, you can use XC test options actions do allow you to do different things and the web drive vision is sits on top of that layer. As I said, as an XC test long running XC test, you can use that and it provides an option called tap. You can use tap to to execute the tap but unfortunately it's very, very slow. The performance is terrible.   And that works much better and it doesn't have that second delay but it still does have like about a quarter second to half a second delay. Because of the way it works. So ultimately under the hood, it calls an XC test a private function called synthesize event. And that ends up being the best way to do this and it's very performant and so I'm actually using a modified version of what drive agent right now that strips out other things the web drive agent does that may slow it down and add more lag. And it's just directly call synthesize event to make the tabs. Another thing that I researched in the process of this was is like, can you run VNC on a phone is there anything that does that any app any method. You know I scoured open source looking for things to do it. There is something but it only runs on jail broken devices. So there's a software called VNC that can be run on vent jail broken devices which works great. And then it shows video and it lets you, you know control it very efficiently. But since it's only for jail broken devices, most companies don't want to use that they don't want to touch it and it also doesn't run on the latest devices or the latest iOS versions. So as I mentioned that in the process of this, it's taken several years actually to find out what are the most performant ways to do this. How do you minimize the latency so that when you're interacting with it it seems as smooth as possible. And that ends up somewhat complicated just because there's there's so many small details that can affect the performance. And you know so besides just directly calling the event, even just things like the number of I'll get into that in the later slide. Like the way the the requests are being executed so like, I'm actually using a nano message partly to accelerate some of this, because if you use HTTP requests even HTTP request one off add extra overhead compared to just sending a message across So, you know when you when you start dealing with the latency of like making it seem as if you have the device in person. It gets very finicky with those smaller details. The next thing would be like a text entry so how do you do that. It also provides a thing. It's like you can call the keys command to enter some text. But unfortunately, if you, if you're typing on a keyboard, and you actually you send those requests to WebDriven or HTTP. It will scramble and mix together your text that you've typed, and you end up with text that's in the wrong order. So you can sort of work around this by doing it slowly and like watching for the responses but it's very finicky it doesn't work. So this is initially and I've actually abandoned it because it's just a bad solution. So, and also you can't execute like certain control can't can't it's like you can use you can sound like an enter key, but like backspace or delete, don't work properly or like home or and stuff like that is not possible. So there's another call that was recently added. This is within like six months ago they added this, which is another private call within actually test which is I wait ID, which is basically like USB devices like keyboards are human interface devices was your mouse is. And there's a call that can actually initiate keys. This call, interestingly enough, doesn't allow you to make it doesn't. So normally when you enter a capital key, you hold shift. And that's actually two calls to the HIV interface, and this exposed API call doesn't appear to have the ability to combine that to like do that, basically do the shift commands so anything that can be done through this is now being done by this and it's much faster than the keys command, but capital letters actually have to go through the other slower commands so I'm actually using a mixture of these two now. And one thing you can encounter in this and I notice is it's easy to get bit by this so if you're using my driver isn't make sure to send the HTTP headers to actually say that you want to reuse the connection. Because web drive region is not using HTTP to which would automatically do that using HTTP one and if you don't do that and you execute many many commands so like if you type like 100 keys just typing normally on the device. You end up using up all your file descriptors on your system very quickly and then you'll you'll have problems. So I encountered this just a heads up for anyone using web drivers and we can call us to it. Make sure to do that. Another option would be to like use a Bluetooth keyboard some people some companies are doing this. They emulate a Bluetooth device from like, you know, a dongle connected to machine. It tends to be a Bluetooth keyboard and then they sending keys that way that does work great. That's one option it's slightly more complex I'm not doing this because it's harder to do. At some point I may switch to this and also the problem with this is not scalable in a data center if you have many many devices, you're going to have issues. You could also use like a USB keyboard so you could like using our Raspberry Pi or something it's someone better device to pretend to be a USB keyboard and then like plug it in through a dongle. So there's advantages to this because you can like get to the task switcher. So like on my phone to be able to view like the running tasks and then cancel out what cancel one out. There's a keystroke on a USB keyboard that you can actually activate that there's no other easy way to get to it like on the newer devices you can swipe up from from the bottom and like an angle to get to it. But on older devices, there's no direct way to do it through a remote control device and a lot of the device farms even the commercial paid ones have this problem where they're like you have to use the accessibility icon to get to the task switcher. It's painful. So this is one advantage of that and this would actually be beneficial and I'll be supporting that in the future. The next thing you want to be able to do is like install apps. The Bible device provides ways to do this. The previously mentioned I was deployed I was I have the thing I wrote also can install apps by using the mobile device framework. The implementation by Daniel pause also provides ability to do this. One thing to keep in mind is just that any app that you install needs to be signed for that device and used to use provisioning profiles. So ultimately what I will be doing is adding support to, you know, automatically do the resigning of apps, so that your build system can create an unsigned app and then send it over to the device farm and then automatically be resigned with the credentials employed to whatever devices The other thing that I mentioned that you need to be able to do is run run tests. This was initially for, you know, the first year of this project. There was no way to do this. I mean, you could do it through Xcode, but it was very slow and it was not scalable. So, because you get one Xcode is very heavyweight on the machine and you can only run one. You only want one simultaneous XC tests on a phone at once when you're using Xcode. And there's also various other issues like you can't do it on Linux because Xcode doesn't run on this. So, and you need this to be able to run WebDriver agent because WebDriver agent as I said is an XC test. So, what is now being done. So like now I'm actually using Go-to-s iOS in order to do this. And it's doing it by, it's a reverse engineering implementation of what Xcode does under the hood in order to start tests. And also simultaneously when that was released, TI device, which is by Alibaba, they also released an implementation that does this. So before Daniel Paul or Bob have released their implementations, there was no open source code to do this at all. Like if you wanted to do this, you had to reverse engineering yourself and no one wanted to share it. And I feel, I feel like the reason why is because everyone's worried that like Apple would attack them for reverse engineering and their stuff. But it's necessary in order to make a device farm. If you don't reverse engineering things, you will not be able to do what is necessary. And like everything like WebDriver is reverse engineered, Go-to-s reverse engineered, the stuff I've written is reverse engineered. And Apple just is mum on the word on this. They don't say anything about it. I've tried to like ask them. I've talked to like a few people. I won't name names at Apple. And they're just basically like, yeah, we know people are doing this. We don't care. So it's a rather strange situation. The other thing you wanted to be able to do is like monitor apps and tests for like I said, CPU and memory usage. The Apple thing that does this is instruments as part of Xcode. You can, so the only thing that actually does this is open source right now is the thing that I wrote iOS, so I looked at what commands are available in the underlying private framework. And I figured out how this works and I made a call that does this, but it only works on Apple because iOS only runs on Apple so far. It can be ported though to Go-iOS and that's going to be in the near future. I'm working with Daniel Paul on that. So I mentioned the proxy here. It's part of a Go-iOS that lets you actually dump anything that Xcode does.  And then you can then see like what Xcode actually did and then you could potentially like extend Go-iOS yourself and then run those commands. So it's very complex. I'm actually, I mentioned like they use a special serialized RPC methodology that was very painful to write. I wish they documented this. All this stuff is not documented by Apple, but you know it's necessary if you want to be able to get the sort of statistics that people want for their tests. And that's pretty much the wrap up of all the different things that have gone into creating it so far. The lessons to be learned from this is to be persistent. And I say this because a lot of people along the way have told me it can't be done. There's no way to do that. It doesn't exist. Apple won't ever allow that. You would have to reverse engineer that and then you'll get in trouble. Like I've been told by companies like people don't want to hire me directly on this because they're like, we don't want to be responsible if Apple gets angry at it that, you know, they're going to come after our big company for creating this stuff. It's pure silliness. And also to try everything. The number of things that I've tried in the process of creating the device farm is absurd. Like, I'd say 75% of the work I've abandoned is not used because it was just things that I tried to try and see like, does this work? Is there any way to make this? Is this better than the other options? Just because you have to go through every single thing to find out the best way to do it. Like, you can't give up. You have to like keep trying, trying, trying, trying. And if you do, you can eventually make it work. And also what I found interesting is that GitHub search has become very useful for me because if you find like specific keywords in code that you know may relate to what you're doing, you can then search for all implementations. And I've spent hundreds of hours scouring all available implementations that interact with phones because it's so badly documented. And the only way is to like find any code that does it and then take that and then learn from it and then create other implementations of it. As I mentioned, reverse engineering is necessary for everything, Apple. Apple really needs to get on top of like actually embracing the community and going back to their hacker roots. They really don't care about the community of developers. It's kind of disgusting. And that's one of the reasons I stuck with this project because I want to work with the community. I want to cooperate with everybody. I'm tired of like, all of the commercial implementations of device farms for iOS saying we want to charge you ridiculous amounts of money. Everything I made everything you see here is completely open source it's completely free. I'm not trying to rip anybody I want to make this stuff work because we need this sort of tooling in order to better automate Apple devices. So that's it. And I wanted to give the rest of the time over to Q&A. And you can see these slides at control4.com is the domain for this. There's very little information there but I did put a version of the slides there. I'm going to need to update them also. It's a slightly older version of the slides. I'm going to add more links to different references. So if you want to learn more about stuff but yeah. All right. Thank you so much, David. So we have a few questions over here. The first one is, can we access remote devices from SDF if SDF is deployed on the cloud? Yeah, sure. So SDF, so the implementation that I did for SDF was the first round of this. It's been a year since I've really touched that implementation. And SDF itself has essentially been deprecated. The community surrounding SDF has forked the project to a thing called Device Farmer, which I've actually one of the founding members of. And I eventually will be contributing back the changes that I made. Like in the process of creating control floor, it's an entirely separate implementation. That's nothing to do with SDF anymore. It's completely rewritten. So eventually I will provide the ability to then provide devices from control4 into SDF so that people can like merge them that way. I'm not really heavily interested in doing that because it's, I spent a good year working with SDF and I don't like the code base. It's very messy. So that will happen at some point, but I really need like funding of like someone to say, hey, we'll pay you money to make this happen because I know how to do it. But I'm just not going to spend any my effort at this point unless someone pays me for it. Okay. Yeah. This is actually series of question. How stable is how stable it current solution for iOS device farm. Can it be used by private companies and how much time do you think it'll take until is also support, it also supports Android. Is it possible to integrate with APM. It has a lock mechanism mechanism which when a device is in use to prevent others to use it. Thanks. There's a couple different questions there. Just the last one first, which is, does it have a reservation mechanism so that one person doesn't interfere with another using device and yes it does. So I didn't demo that but when you select a device to view it it actually shows that it's in use by another person and then you can then kick that person off if you choose to do so and there's an options for that. As far as it being stable or not right now. Yes, it is stable. This is currently being deployed by some top companies on my main client which I said wishes to be unnamed they are actually looking to deploy it to more broadly within like the next two weeks. And as well a T mobile is going to be using the solution you know they they purchase the software for me, and they're using it now as they're going to be using it very shortly, I guess they need to contact me and work it out but yeah. Lambda test is also integrating this currently so they are using this behind the scenes to provide their offering for iOS devices for running to control them so like of those solutions. So this is really one of the best ones will be lambit test because they're going to they have their own employees that will be adding additional features and you know monitoring stability and making sure it works as well. So this is like a one person project like I am the company I'm the person who created all this. So I work with Daniel Paul us somewhat, but I'm only loosely sponsoring his projects, like he's I wouldn't call it to work because I'm, I'm only slightly sponsoring this project is not very much money. So, you, despite that this project has been multiple years it's been several years creating this so it is very everything has been done to make it as stable as possible. And it does also run on both Mac OS and Linux at this time. I'm currently working through some issues on the next version, the Mac OS version is the most stable at this point. I've seen some issues with like go line 1.17 but if you use go line 1.16 you try to Mac OS it's very easy to set up. If you're regionally technical you can probably get this set up within an hour and have it running on your device is it's meant to be as straightforward as possible and not confusing. I think I missed one of the questions in there. What about the, is it possible to integrate it with APM. Oh yeah, yes, integration to Appian. So, I sort of mentioned this in the middle of the talk which is that with 2x code you can't run multiple xc tests at once you can through go to iOS and through ti device. And this is important because like I'm using a modified version of web drive region, which is the underlying support for Appian, like Appian needs that in order to be able to work. So you can simultaneously run support for connecting to the device farm and for running web drive region and then running Appian on top of that. And I haven't added the support for I will be doing in the very near future of like making it automatically start up both web drive region and Appian for you. And what I'm going to be doing is actually making it so the way the security model works for the system, unlike, you know, the modification for STF is that all the commands you access go to the server portion and then the provider, which then turn connected to the device. So you don't interact with that provider directly so like, essentially the endpoint for Appian will be the server portion and then automatically forward all those what driver calls over to the device so that then that web drive is actually authenticated. And Appian doesn't actually work this way right now it doesn't have any authentication. So like it expects that it's just using an open web drive region and that's going to be slightly different so I'm going to have to tweak that slightly for Appian but right now you can just run your own web drive devices that are connected to the farm and that will work. But I'm going to integrate that a little bit better in the near future. Right, okay. So we have one last question. Is it possible to build smart TV farm, any suggestion on how to start. Yes, so Lambda test has actually asked me to add a support for the Apple TV device. So these devices right now. It should be doable. I don't yet know all the details of this because it's mainly I don't know if it supports like upload broadcast extension like the iPhones does, which is the current way I'm showing video live from the device. If it does then great then that'll work perfectly if not I'll have to use some of the other video mechanisms that I mentioned. So I have support running web drive region web drive region already has support for it. So it essentially should work and you know, like I said I'm working with Lambda test and they are paying me to add support for it, or they will be. And so probably you'll see results for this working maybe within a couple months from now. So I have a lot of other things to do as I mentioned like the whole slew of things that requirements, mainly only the basic bare bones MVP stuff is working so far, but it's, it's stable now and that's what I've been working through for the past four months is making everything as stable as possible so now that stability has been reached, I will be adding a lot of the additional features and like I said is also as well making the TV device work. So I think that brings us to the end of the session and David. Thank you so much David for sharing your experience today. Thank you for joining my talk as well.


from but it has been found to grow on the surfaces of farm equipment so it could be that there's a place in the environment for this naturally and that it's found an opportunistic place in farm salmon in terms of the infectious agents we see some viral diseases particularly resulting in some heart problems in fish and of course you mentioned the synergy between different problems if fish are affected by heart issues then and the gills are also affected then it puts a respiratory challenge on the fish I would also agree that the availability of the veterinary advice and this is another thing that's changed since 2002 the availability of specialised fish vets has expanded massively we've got laboratories that support them so the industry do have access to vets who obviously have an ethical obligation for the care of the welfare of the animals so that aspect is certainly covered in terms of the legislation Does anybody else have any comments? Could just come in from the planning authority point of view the actual mortality rate is to say will not be a material consideration for the planning authority in making its decision there's enough positive obviously we take our decisions in reference to policy, national and local and there's certainly enough positive policy in existence to suggest that the industry as a whole the whole setup of of agriculture is something that the government wants to support and local authorities should support it one of those factors that we would take into account there Alec Rowley in Mark Ruskell Just on that point you made about the material consideration would the material consideration be however that we've seen that the level of immortality was around the 90s and 2000s 20 per cent of fish stock and that's risen in recent times by 25 per cent how that's disposed of so we see the lorry runs the salmon runs as they call them the lorry loads a dead fish millions of fish that are being killed is that a material consideration when looking at planning? It could be it's not one that's been raised with us but I think if it was raised that we needed to think carefully about how dead fish would be moved from the site and presumably through the road system I'd certainly be looking for comment from my roads colleagues and Transport Scotland perhaps on the appropriate way of doing that and other regulators if indeed the transport of dead fish raised other regulatory issues it's not something that's been done so far but I think that that would be material a physical impact on the road system or raises other issues Robin Meenard Marine Scotland Science the fish health inspectorate a statutory consultee in the planning process and in relation to our responses with regard to our responsibilities on fish health we will be taking account of whether the farm has in place the provision for dealing with large scale mortalities and indeed on the authorisation process that we undertake with the farm through the biosecurity measures plan they do have to have in place protocols and procedures for how they will be handling mortalities in fact removing mortalities also from the cages environmental effect the farms are removing mortalities on a very regular basis and that's of course is minimising pathogens going into the environment in relation to the impacts on wild fish which is referred to in the Sam's report from disease we take a slightly different interpretation to themselves on the Wallace 2017 paper which we interpret as and it was conducted by Marine Scotland Science we interpret that as including a lot of very structured surveys that provided the evidence that in actual fact the impact of infectious disease on wild fish was likely to be very minimal and on that basis we've actually focused our resources on to trying to understand the sea lice interactions as being a more beneficial use of the resources that we've got available but thank you convener could I just take up the issue which my colleague Alex highlighted about the transportation and disposal of dead fish which is particularly important in view of the mortality that's been discussed this morning and ask any of you as regulators or as a local authority whether you have a view on whether the regulations and the protocols and the possibilities of prosecution and enforcement are appropriate and I just refer you to an FOI which produced evidence about something that I quoted in the previous panel session about an accident on the A9 and the FOI shows that the police only reported this is what the FOI shows I'm just clarifying that only reported that to Bear Scotland and the incident was a photographic evidence shows that the incident was that there was a lorry with simply a tar pulling over it and I stress it was photographic evidence which I've been shown so I wonder if there's any comment in view of the amount of mortalities about if we've got it right and if not, how we should change it so CPL doesn't regulate the animal byproducts order but we certainly regulate the transportation of waste and in respect to the mortalities now that there is no longer a derogation for disposal at landfill sites we are concerned about the previous question about concerns around the level and volume the facilities that they're receiving these dead fish are licensed by ourselves under different pieces of legislation and quite concerned to ensure that when they arrive that they're not then giving rise to problems within the locality like any other waste stream particularly organic wastes so there is and we will be exploring in more detail with the industry because we license on the basis of environmental impact concerned that the numbers are then not lending out to the product in which they're been licensed for and the sustainability of that from an environmental perspective together with the transportation and then the on-going issues that may then present themselves further flung locations transportation is any delay can then give rise to a problem at the point of receipt and clearly that is part of that wider focus in terms of our regulatory approach which is to look at the entirety of a sector in this case the fish sector and looking at all avenues in which we regulate it to ensure that there is full compliance down that line that is the discussions that we're having at the present time to have as we move into the sector-based regulatory approach that we're doing underneath our regulatory strategy Just before anyone else comes in if they want to could I just ask you for the record how the dead fish are disposed of so there are energy from waste facilities that do receive that material so anaerobic digestion plants that receive it, they are further flung so one of the key things is identifying a proximity solution for a range of organic wastes and I think that that is an essential part of the discussions that we're having Is there any other comment on that question? You're interested in what happens in terms of the environmental aspects of the waste there's a report by Zero Waste Scotland in 2017 that I don't know if you've seen it but it looks in essentially it says that this waste is actually quite valuable because of the lipids and the proteins that are in it it's actually high quality lipids and proteins and it identifies routes in which the products can be used even in areas of farm cuticles Right and thank you for that, I didn't know about that but also in terms of the actual transportation or remit Transportation, no That you have concern about We're concerned for sure that the transport needs to be contained from the spillage point of view How should it be contained? It should be contained to prevent Is a truck with a tarp pull and a top acceptable? There's no what generally speaking is regulators who don't specify this isn't my area of regulation So whose area would it be? I'm not trying to quiz you I just want to find out whose area would it be because there has been concern expressed about this environmental aspect of spillages and that The answer is I don't know is that it might well fall to either the roads authority as a local authority or the trunk roads The animal by-product regulations are enforced by the animal and plant health inspectorate and in respect to the transportation like any organic waste you would expect certain levels of containment from an environmental perspective concerned about the potential in that particular scenario that you made reference to must be around discharge into watercourses and the on-going issues that might present but in terms of animal by-products it is the animal and plant health that are the inspectorate purely because it is an animal by-product in any other context it would be duty of care and under the environmental protection act fall to waste legislation controls which would be SIPA but there is a lead authority purely because it is an animal by-product and that is not ourselves but another agency Cross call wants to come in briefly Mr the issue of transportation of ever growing numbers of dead salmon is really a symptom of a wider problem so can I come back to the issue of salmon mortality again can I ask Rob Reynard what is an acceptable level within a salmon production system we have seen figures referred to in the previous session of 4% 40% from a fish health perspective what do you see as an acceptable level for a production system I don't think we can identify what is a desirable or acceptable level it's 40% acceptable it depends what's driving the cause how that's a recent change what's the industry doing about it I think the context is critical and I do know genuinely that the recent increase as I said before is largely driven by environmental factors and industries including those in Norway are joining forces with Scotland to actually understand what those are and what the solution is it's not something that we like nobody likes but people are quite concerted in the way that they're approaching it and it's an international approach to solving it there is the there's an international group called the Gil Health initiative they meet annually it's industry, researchers, regulators they actually look at how the science has moved on what's causing this, what are the solutions and we heard some of those solutions from David this morning and those types of fora are where best practice is developed to tackle that so if the industry has a high mortality and nothing's done about it is that acceptable, no if they're tackling it and it's driven down is that a good thing well that is a good thing it was mentioned before that other livestock industries have mortality issues you mentioned there about context the context of this inquiry is that the government and industry want to double production by 2030 do you believe that salmon mortality will go up or down if we double production as a percentage terms and what do you see as an acceptable level of salmon mortality, is it acceptable the caution of the fish die before they go to market just to clarify a point the aquaculture industry leadership group identified the target the Scottish government support the target if it's reached sustainably and that is the question so would we support a doubling of production with such a high mortality that's a more difficult thing to say but what was coming out from the discussion this morning was that the industry will need to address these mortality issues in order to be able to expand so is it being reached is that target being reached sustainably at the moment given the mortality levels that we have I think mortality levels at a certain level given that if the mortality is having an environmental impact then it's an environmental issue but a lot of the mortality at the moment isn't having a big environmental aspect and is more of an economic sustainability and in terms of economic sustainability that is more for companies to address so just to quantify this let's come at this from another direction to assist the line of questioning Mr Ruskell's developing mortality rate in Scottish aquaculture compared to aquaculture elsewhere take Norway for example okay so Norway are currently experiencing mortality events in the region of about 20% which the long term average in Scotland was around 20% and it's gone up largely through these gil health environmental issues and the associated treatments to tackle that but the mortality the mortality in Norway is also something that the industry and regulators are keen to tackle as they are in Scotland so we're not saying it's acceptable but we were told last week that there was considerably more science taking place in Norway than there is here to look at these issues is that the case? by and large that is the case and we often the techniques and technologies that are developed in Norway are often transferred across into Scotland and Ireland and indeed Canada and Chile and I mentioned the gil health initiative which brings industry and scientists and regulators from across the sector, the international sector together to share best practice I think everybody wants to drive the mortality down and in terms of what the government is doing through its development of the farm fish strategic health framework is the right thing to do bring everybody together and tackle this cohesively okay just to wrap up this section Richard Lyle briefly in my mind's eye I am getting picture of dead fish on a lorry swallowing about in the road depositing liquid on the road surely that is not the case surely we have a big self contained lorry that does not leak on the road surely that is the case of Amarón yea right sometimes tankers can be used tankers are very sealed I guess it comes down to the availability of vehicles at the time but it is not that is no excuse for not complying with what is required of the regulation why can't it be handled on the site if fish are dying locally at a fish farm is it because 3% has got to go to a certain place or is it because the facilities are not there or is it because they are not invested in something that they could do something with fish there are small bi digesters that are available to put into sites that can deal with in most cases there are small mortalities that are almost inevitable but these large scale mortalities they are of such volume that they really have to be dealt with off site the maintenance of a digester for example that could handle 150,000 fish would be huge but it might only be needed on a site once every five or six years if that so it's about the cost and benefits proportionality very briefly one is that we saw the BBC following lorries along narrow roads stuff coming at the back I want the roads and whatever we've seen that transportation of the dead fish is not what should be but could I pick up on the point you made Mr Reynard, where you seem to say that having all these dead fish did not have any impact on the environment it was simply an impact an economic impact I mean that would be stretching that a bit surely there is with that level of mortality and there is an environmental impact there is then what the companies are doing to try and tackle stuff like sea rice so is it not a big leapy face to say that there is no environmental impact of fish farming and the fact that 25% of fish farmed are basically being killed because of the disease a clarification I guess there will be some environmental impacts but what I was trying to put her forward was that in terms of disease because the mortality is removed on a regular basis the environmental risk from the disease is minimised and then it becomes as you say the environmental aspects of the logistics or the loss of biological production by the business which has had environmental import to generate there is that aspect to it so yes there is an environmental aspect just quickly perhaps just to put that in a more ground package that hasn't been mentioned so far most fish farm planning applications come in as they're considered to be environmental impact assessment applications to cover that ground and come in with an environmental statement I think I'm right in saying that most environmental statements will include a short section on disposal of of mortalities I suspect certainly in my mind now that maybe that's an area that planning authorities just need to put a little bit more emphasis on or indeed the applicants need to put a little bit more emphasis on to cover these questions because these questions really shouldn't shouldn't be existing if it's a feature of the farm in its production then at least the impact on the road is an environmental impact that needs to be addressed and perhaps in that context identifying a location for the disposal of these fish as well picking up on an Anderson's point I think you'll probably need to go that far yes do you look at the discharge of medicines into the marine environment John Scott? A quick question for Sipa for Anderson can you tell the committee about the recent work you've done around the environmental quality standards for emecton benzoate and where do we go from here so Sipa ememecton benzoate has been operating to environmental quality standard that was set a number of years ago and in respect to the recent work that we've done we commissioned a desk-based study of all the available intel in respect to ememecton benzoate that concluded that and recommended a tighter environmental quality standard that particular piece of work is going to the UK technical advisory group on a body that is set up under WFD which utilises the principles under the environment European Union directives to ensure that there is consistency in the setting of environmental quality standards so that particular report is going to the UK TAG body for a peer review exercise as is common with any scientific document and out from that particular process do we expect to get a response to the body of work that's been commissioned to date the intent then is for it to be provided to Scottish Government which again is consistent with environmental quality standards under WFD and receive a Scottish Government direction for the use of that standard in the interim period we have information that lends itself for a tighter control of MMI and have put into place a position statement which accommodates the current situation up to the time when that piece of work is concluded the focus and protection is at the precautionary end in respect to all new applications where there is a marine protected area or a priority marine feature identified through that planning and application process where there are features that are believed and identified in the process where MMI may impact that tighter standard is being adopted and is placed in respect to that measurement and usage of so at the present time that process is under way it's moving through to the UK TAG over the course of the next month and then we're waiting for the output from that particular piece of work we utilise the best available information and we then identify where we need to employ that stricter standard and certainly in this case we have done so in areas where MMI has not been utilised before and specifically where we have a population or sediment of concern Thank you and can I just ask you as well generally about should sediment quality be incorporated into Marine Scotland locational guidelines as suggested by Professor Tett last week and all those you've put out so we use in terms of the assessment process there is a locational guideline document that we use and we also use the additional information to hand so there's a range of different packages of information clearly having it all within the one frame would be a step forward it would be a positive improvement the overall assessment of cumulative impacts and spatial locations is an area that I'm certainly very keen to explore with other regulators and we've been discussing that aspect because there are as I think identified last week there are gaps in the information and ability to fill those gaps is key I'm going to bring Mark Ruskell in the minute to a supplementary question and to move this on into the issue of nutrients but can I just pick up on the more general issue of marine protected areas and protected features the report indicates in 2003 there were 16 salmon farms sighted above Merrill beds we've learned since that there are currently 25 located within MPAs that are designated for Merrill beds we also told it two years of following does not allow recovery of beds why and after we allowing the salmon farms anywhere near these features in respect to the information available at the time we do a baseline assessment that is undertaken and we analyse the information available from other bodies so every application is assessed on a range of environmental factors in respect to the Merrill beds there are recorded in and around the reference stations reference stations are outwith of the zone of the actual impact so they're the baseline set aside and in terms of that available data we have got recognised information it forms part of the key aspects of a planning of the car application process the need to do that baseline and seabed assessment and provide that information at that stage to identify whether or not there is a marine protected feature present and in this case Merrill beds so sorry in layman's terms do we have fish farms located sufficiently close to Merrill beds within the NPAs where they could be having an impact is that happening or isn't it so the information I have is that there are 29 sites which are currently recorded positioned in and around areas where Merrill beds are present of those 29 Merrill has not been recorded to be present recently at 13 of those facilities so the answer would be yes there are in and around the location of and the identification of that those are existing and on-going facilities so they're having a detrimental effect on the Merrill beds I am I can in terms of that the facts I have is simply that there have been recorded presence of Marl there is now currently 13 recorded to be present at this time period and that's from respect to recent information right Mark Ruskell Do you think that there should be a phase out on the use of Emma Meckton and if so, over what timescale? SEPA has undertaken a reduction in the use of Emma Meckton blanket variation applied to all active and closed operating fish farms so those operating currently and those that could operate in the next cycle of the quantity of use of the medicine the environmental quality standard the tighter environmental quality standard itself the position and the assessment point hasn't changed that in itself will require a reduction in the use of Emma Meckton by default Do you think that that could lead to a ban on its use? I think that in terms of the decision and the output I'm aware that there are additional research being undertaken at the present time in terms of the ecotoxicity of Emma Meckton then to it so I referred to a desk study that was undertaken based on laboratory information there is a proposal and a research project under way which ties to mimic as best the marine environment so the output from that obviously add to the science in this area it continues and we as a regulator keep informed and react to that changing scientific information If I could turn to nutrients you heard the last panel on their reflections on the new DZR regulation which SIPA are putting forward but you also would have heard some concern about the lack of scientific evidence to underpin that Where do you see the DZR regulation going and should it not expand perhaps to all fish farms why has there been an approach on only looking at expansions in more exposed locations why not the entire industry I don't understand this The DZR consultation has closed we are currently reviewing we received 144 pieces of information from a range of stakeholders both industry communities and other regulatory bodies part of the approach is in respect to the transition so the introduction of a new regulatory approach to fish farming I would envisage that being a transition across the entirety of the fish farm licence process DZR introduces additional monitoring it adds to the information base it also is an approach that allows what has been referred to as adaptive management there's an element of that under the current car environmental licence controls and it's how SIPA as a regulator works is to take the evidence and then to pull back and undertake an action if it's not predicting the environmental impact that was expected so DZR is actually providing a greater level of monitoring greater level of evidence and for us then to be able to assess against that and for the business then to adapt within it's zone of impact Claudia Beamish I think there's a supplementary before we move on to the COIs Thank you convener Could I come back to you please Ann Anderson and ask you in relation to MPAs whether you've highlighted mill beds whether in relation to either mill beds or any other protected feature there is any regulation opportunity if thought necessary to actually stop the activities of a fish farm if it's environmentally affecting an area which is protected and what would that process be if it exists part of the car consenting regime and I will provide details of that particular process to you so I'll do my best just to summarise with that aspect SIPA is a competent authority in terms of Natura we undertake a habitat impact assessment and we also consult with SNH to ensure that we've got the accuracy of the information part of that is to ensure that where we are permitting that that permit is in compliance with the range of environmental information so the habitat impact assessment is done in those instances and specifically with the view as we do on land based activities with SSI process is the same level of protection is provided recently with the MMX Invento we extended that to include priority marine features as we recognised the species rather than the fixed place an identification of a species within an area was particularly important given that it was a medicine thing so in terms of the controls that we put into play that does form part of that assessment process and is something that has become more self-evident over the recent years some of the facilities we referred to earlier are facilities that have been established for quite some period of time if you like of the Finfar sorry I still don't understand in your answer in terms of what I asked is there the possibility how is it monitored once it's happening and is there the possibility of stopping activity if there is shown to be a detrimental environmental effect and if so what is that process in terms of the seabed monitoring and the limit in terms of benthlic and that's based on the information that's present at the time of the application in respect to MPAs there is that assessment that's undertaken under the habitat impact assessment process that's a body of work under natural legislation then any non-compliance with the benthlics requires additional seabed monitoring do we have video evidence of the seabed underneath so there's a stage approach that's then taken in that process and clearly if there is an impact we have the ability then to adjust and or revoke licences any examples of licences being revoked in those circumstances I'm not familiar with but I will check and ensure we certainly do reduce the quantity of impact from farms when we have had failing benthlics it's a very common approach as a regulator to pull back I'm not aware of the specifics of that but I will ensure that I capture that so they may be scaled back in what they're allowed to do is what you're saying but I'll be interested to know how often that has happened and also whether there have been instances where a licence has simply been revoked because of the impact that was identified and revoked but I will provide you with that the accuracy in the detail Claudia Beamish on COAs and indeed if there is the power to do so to revoke yeah, thank you right, so if we could move to sea lice and I'd just like to highlight from the SAMS report for the record as I did last week that some sea lice are a key impediment to the Scottish salmon farming industry in the marine environment and that's the scientific research the peer reviewed research that we commissioned as a committee you will have heard today the announcement by David Sanderson I think about the real time public reporting of sea lice data which was something that was bought forward but not accepted in the aquaculture bill which of course is now an act over five years now do you have any comments any of you from your perspective on the situation in terms of real time reporting and if there are benefits to the reporting being publicly available and if those are in relation to either disease or research that would be very helpful I think any publication of information in this area is really important for ability to be transparent SIPA publishes on Scottish aquaculture website information that we receive and any aspect then is something that any access for any particular work is a beneficial move that the industry have chosen to do and I think that the information around sea lice mapping and locations relate to I mentioned earlier about the interdependencies so being better informed can only be a good thing going forward just before we move on I should have also posed a question to you Ann Anderson about whether in your view or do you have a view as to whether that should be a legislative requirement of the industry I think if it is consistently provided that's the key point what if we believe that there is a need for it I think a regulatory control it requires that to be then applied as I think was pointed out the Scottish salmon producers organisation don't represent the entirety of the Scottish industry and I think it is relevant that we are talking about the entirety of the impact on an industry in Scottish waters that all that information is available at the one time to add weight to the to Arn and D work are there further comments from the panel on that particular aspect of the sea lice issue could I come in just to say it's very welcome publication of the data I suppose I speak obviously because we represent that local democratic and public accessibility to our work is part of our day to day I think it could make a very big change to our work because it's always been a frustration that information about sea lice numbers were difficult to come across certainly on a site by site basis if that's to be available I think one can expect to see a great deal more public comment upon it and certainly we as a local authority are going to have to be ready to be able to handle that comment the other point I wanted to make of course is it it effectively answers one of the questions that our use of environmental management plan conditions has been aimed at achieving which was to allow the authority access to site specific information on sea lice and because of sensitivity about FOI and so forth we are trying to work out arrangements to receive that information on a face-to-face basis so there wasn't any exchange of information hopefully that will not now be necessary and that will allow the focus of the EMP to become to move much more on to the issue of wild fish monitoring the other aspect of it so I think that that openness within the planning system is just a good thing full stop it should be statutory because that allows regulators such as myself to be able to rely on it without getting into unnecessary arguments and costly requests for further information and so forth Are there further comments on that? Thank you Yeah I think good access to data is important for the research and the provision of advice from that research regarding planning etc I think it's not just about real time I can see that real time might be of interest to local authorities etc often from a research perspective one is looking at long-term data sets and you want to be able to compare fish data with sea lice data so having availability to historic data is also quite important strategically I mean our approach at the moment is to work in collaboration with the industry on the availability of data to a large extent that's worked quite well but there have been occasions where it's as Mark has mentioned where it's a bit more difficult there's the work in addition to what David has said that is being focused on in the fish health farm fish strategic framework group availability of data in general and so you know I guess we don't mind how the data is made available but it seems that that availability is improving right thank you and I've got I have three other questions about sea lice I'm going to ask them all at once and please do not feel an obligation to answer if it's not within your scope obviously I'd like to know Mark Harvey's already touched on the potential wild salmonoid impacts of sea lice and I would like to know whether there's a view on removing that from planning into a separate regulatory process would be something that's being considered and is it of any value in your view how is the duty under the Nature Conservancy Scotland Act 2004 discharged with respect to salmon farming and that is as you will know a record that all public bodies are required to further the conservation of biodiversity and finally are there any comments on the appropriateness of the triggers in relation to sea lice for the reporting mechanism and so I would just open that up to panel members please Maybe I can kick off with the last element of your question of the triggers Essentially yes, for the first time we have a need to report sea lice above a certain level it's an average of three female lice per fish and then there's another level which is statutory intervention level of eight how appropriate are they I think the purpose for what they're designed to do which is to enable the industry to avoid the occasions where big peaks occur then they are appropriate the basis for that is the both through discussions with industry's own experience of where lice have got out of control on individual farms that keeping lice below three is a very important level and where lice get above three there's obviously increased risk that numbers escalate on a farm without a plan in place so the new measures allow the plan to be put in place the fish health inspectors to monitor the outputs of that plan and to take enforcement action should that not deliver the results so could I just ask you on that I understand that the SAMS report says that there's no published scientific account of the basis of the setting of the trigger levels in the new sea lice policy so could you clarify for us how those were decided and why do they differ from the code of practice levels so you're correct it's not published the level of three fits with the we did some analysis the long term analysis of the data that industry provides through the SSPO's reporting areas when that is modelled three emerges as the kind of upper mean level which indicates that most of the industry are staying at an acceptable level the requirement of the law is to have measures in place for the prevention, control and reduction of sea lice and demonstrating that the measures are in place we felt was indicated by whether one could stay below three or not so that graph that I spoke about fits with the decision to make three it's not based on pure science that really is a kind of adaptive approach and we've agreed to it's obviously bedding in we've agreed to review that after 12 months which will be July this year and the analysis that we've made of the industry data what we've got there is a Scottish model that we're about to publish on that so unfortunately it wasn't available for Sam it will be published very soon and that's showing that the seasonally adjusted level sea lice go up and down based on season and the seasonally adjusted level at the moment is the lowest it's been for the past three years so it's come down over three years from about an average national level of 2.5 to around about 1 so that's one average female louse per fish as a national average but of course the measures we've got in place are ensuring that individual farms don't lose control thank you sorry I should point out that the SSPO's codical practice numbers of 0.4 and 1 aren't limits that are set by either the SSPO or ourselves they are the level at which veterinary intervention should be consulted right thank you so are there very briefly any comments on the other questions from yourself or anyone else on the panel I've come just again planning authority views slightly different you've mentioned the biodiversity duty the biodiversity duty is very much in planning authorities we need to understand their minds when it comes to the protection of wild fish in respect of sea lice that's really where we continue to emphasise that we need to show in taking a positive planning decision that we are addressing that biodiversity duty as well as we possibly can there's room for debate there this discussion of triggers probably your first and your third question from my point discussion of triggers probably is a good example of why these matters are best left in the planning realm not exclusively but I think it's important that there's loads of control because it seems to me that this assessment must be site by site in our own area we have SAC rivers so that these are protected rivers some of them protected because they represent some honoured breeding areas some of them because they contain freshwater pearl mussel populations which rely on some honnids to distribute the young mussels and continue that process clearly when we're looking at a planning decision therefore there are sites of greater and lesser sensitivity and I think it would be appropriate therefore that we're applying perhaps less tight control on control on sea lice numbers so I think a one regulation or one set figure that suits all is not necessarily appropriate we can move on actually to perhaps the issue of wildfisher at a later point any other comment thanks Richard Lyle I've got two questions I'll try and be brief there is a desire to double our salmon production but we have as I see it amongst others two problems 20% fish mortality over 20% in fish escapes over two million fish have escaped in the last 15 years ok people may say oh it's only 147,000 a year but it's 147,000 too much so does a fish farm face any regulation consequences if fish escape and do the report escapees to anyone at present yeah so reports of escapees are provided to fish health inspectors there's a requirement for Fisheries Act for businesses to report an escape or even suspicion of an escape there's a requirement for farmers to have in place measures to prevent and control escapes as well following an escape fish health inspectors will visit the farm and investigate whether or not they consider best practice in relation to containment had occurred at the moment much of the inspection is focused on the elements of the codical practice which is considered to be best practice plus record keeping elements that are required by statutes and as mentioned before David Sanderson mentioned that there's an development of an industry a Scottish containment standard that could become part of that in the future to make things more robust so the inspectors will take any enforcement action depending on what they find so they find are they fined or is it just a you lost fish so try and do better than next time no there's no fine for escapes in Scotland there's the measures that are in place under the act are that an enforcement notice can be issued and that's obviously not complying with an enforcement notice is a criminal offence but many of the issues that are found are dealt with through written correspondence so no one's taking to court no I'll move on there's a notification to assist on that line of questioning the 140 odd thousand fish every year that we know escape is that indicative of a widespread problem or is it largely made up of a number of relatively small incidents of large a small number of large scale escapes the large scale escapes tend to be associated with extreme storms often storms where people end up dying in Scotland which is we don't want any of that to happen but occasionally it does the data for the last three months is there were five escapes reported one had six one had about sixteen hundred two had zero because they were suspicion, they reported suspicion of escape so that would be maybe a small hole because the nets are frequently inspected maybe a small hole is found and that's reported as a suspicion and another one was five hundred so it's pretty varied it is varied, yeah so there's quite a lot of incidents then based on what you've said to us smaller amount but why you've varied what monitoring research is taking place to understand levels of integration in Scotland does more need to be done in this area yeah I can maybe continue with that one Marine Scotland's exploring the development of a regular system to of national assessment for interagression one of the challenges there has been research looking at integration in Scotland it's reported in the SAMS report what's not mentioned in the SAMS report is that something that's hindered the research has been the past practice, it doesn't happen now but historically some farmed fish were deliberately released for restocking purposes into some rivers and those genes because those genes are present from historic it's not really anything related to escapes because they're there historically it means that the genetic tools that have to be developed are much more difficult to do so but Marine Scotland have an assessment in place to look at that okay, thank you thank you Mr well, Stuart Stevenson a very quick question with a quick answer I suspect do the Government and any of the regulators have a role in regulating farmed salmon food nope, I've got a shaking head there oh sorry nesan doesn't under dependent on the scale and size of the feed processing plant we do have feed processing plants in Scotland that are required to have a permit under pollution prevention control legislation and there are areas within that that pertain to raw materials and resource efficiency would that address the issues sustainability and influence the balance between sea based product and vegetable product it certainly allows the potential to have those discussions to date they haven't taken that route because it has largely been a resource efficiency issue around energy and water and other materials but in terms of our approaches going forward it will be featuring right, so we have the powers we're not yet using them right, moving on the report we have as a committee it says a number of things on the list additional regulation of shooting could improve seal welfare e.g. through the reintroduction of closed seasons for shooting corresponding to the main nursing periods for sales validation of shooting reports and additional post mortems and shop sales could increase the proportion of clean kills is there seen by any of the panel members as a need to act on any of these issues yes in relation to the shooting aspect I think it's important that we always maintain a position which is clearly that the shooting regulation, if you like, the legislation was brought in to helpfully reduce it in terms of the restrictions you would place in terms of protecting the population yes, those facilities are available within the regulations and conditions can be applied to licences to restrict during periods of concern with respect to say season etc ok, thank you and finally on the issue of ADD noise related pollution is there a case for better monitoring and licensing well absolutely in the sense of the interest in the subject earlier on today one can tell for discussions that are quite different opinions which makes it rather difficult sometimes to bring some sort of common place some common theories into place however, the bottom line is that in the SAMS report identifies the necessity to do more work we would agree with that it's important for that to happen Marine Scotland as an entity has a desire to pursue that we would work collaboratively Scottish natural heritage I think that what's most important is that in making decisions on whether you want to regulate need to regulate, there's a requirement to regulate it has to be based on good evidence and in doing so we have to be able to collect it there are pretty much pretty good bits of evidence out there but they are quite different so you have to be able to take a balanced view which is really difficult in respect to making proportionate decisions and look into what you might actually be restricting in the future if that's the route you would take so at this point in time we don't lose sight of the necessity to give it a very rigorous consideration and we would work towards trying to get ourselves to a place to make a decision Who's got the lead, is it Marine Scotland or SNH? Marine Scotland would work collaboratively SNH yes very much so SNH would be important to that decision making as would others like the CMAMO research unit and indeed others like Marine Scotland Do you forgive me who's got the lead? It would be ourselves who would presumably be able to take the lead in that we would expect to do so at the moment Oh yes Sorry, it was only that this issue of ADDs was rather thrust on us in the last couple of years because my general area of work is sky and the water surrounding sky are now a candidate SAC for harbour porpus so it immediately became a much more important material consideration for us. Our response to that is actually to put a condition on any permission granted that requires the operator to retain a log of ADD use but actually more importantly and above that through discussion with SNH because SNH obviously are also facing a situation where retrospectively they may need to look at the use of existing ADDs on existing farms and potentially take action in terms of requiring adjustments to the way in which they're used As a result of that we've also been looking at whether particular equipment can be tuned because obviously we're talking about sound frequencies underwater here whether it can be tuned to affect seals but not of course affect harbour porpus and indeed other cetatons which is a similar problem so both the planning application stage and subsequently through the compliance of the condition we are trying to control this one because obviously the existence of an SAC makes it a pressing issue for us. I don't want to open up a huge subject but presumably we're monitoring noise at the torpedo range adjacent to Sky which is adjacent to the SAC anyway. Yes although we're not feeding that information we're not trying to feed that information at the moment. I'd like to ask Mr McKee about the regulations that we have in place which allow the killing of seals in Scotland. My understanding is that this falls foul of the United States Marine Mammal Protection Act which quoting the act prohibits the intentional killing or serious injury of marine animals mammals in all fisheries and as a result of that we could be facing an export ban just on Scottish salmon but indeed all of our fisheries products in four years. Can you tell us what Marine Scotland is doing to try and address this situation? Are you for example looking at withdrawing that regulation which allows the intentional killing of seals or are you lobbying Mr Trump to try and change the regulations? Thank you. The position is at the moment in relation to how we're tackling it directly is that's a matter which is being dealt with part of Marine Scotland and indeed in a wider part Scottish Government to understand exactly what it means in terms of what's required, what the expectations are and then from there that will then feed back into how we then react from a regulator perspective so we don't yet know exactly where we are going at. How much concern is there around this because the words in the US Act are any regime which allows the intentional killing or serious injury so intentional killing is what we actually have in relation to seals. We have a license regime for that. Whether serious injury caused by ADDs or other techniques which may scare away Marine mammals is another question but I think it's quite clear we've got intentional killing. Obviously I have to say that from my perspective clearly I'm at the sharp end there's people who are sitting behind that and it is a case of, it is a concern yes it is a concern, it's been treated as a concern and discussions are underway to try to verify and consider exactly what it means and then obviously that will then help to feed into the decisions going forward. Time scale for that because if the salmon industry loses the US market I would imagine that's pretty chunky. I appreciate that point I don't know the answers to that but clearly that's something we would need to come back on. Can we see on that to the chair? That would be a good use. No problem, thank you. Thank you, Finlay Carson. In the use of wras as a cleaner fish is there any need for additional regulation of the well fisheries to deal with any impact? I can answer that. So Marine Scotland's holding discussions with all stakeholders in the industry and fishermen as to what management needs to be put in place we're quite, obviously quite serious about needing to protect the environment with the numbers being taken out and we know that the fishery in south west England is managed sustainably so what we've done already is licensed the fishermen required data collection from landings and that will be important data that's put into the management subsequent management of the fishery and there's discussions going on this month to decide what needs to be put in place before the fishery starts in April Finlay, just on the subject of mitigation Alex Rowley Good question Fisheries Management Scotland have said that the regulation system for the salmon farming industry is unusual because there is no formal requirement for pre-application or post-consent monitoring of well fish as there is for many other developments why is that the case and does it need to change? In terms of post-consent monitoring we'll go back to the environmental management plans that we've started to introduce in planning applications I think that's as far as it gets so I think the answer from a planning authority point of view is yes we do think there's a need for post-consent monitoring these are unusual planning commissions and obviously they are permanent planning commissions they last forever different cycles it's not like granting planning commission for a building it's there, you can pretty much work out what it's going to do these are active and consequently there's very much should be subject to ongoing monitoring I don't claim the EMPs are the perfect tool but they are something moving in that direction The final question from John Scott John Scott You may have heard me discuss the possibility of engineering solutions in terms of scooping up when gathering the detritus in below FISFARMS and the possible development of that to scoop up the waste Do you think that engineering solutions are part of the answer to the deposits that are placed in seabeds that carry all the attendant risks that may carry the attendant risks that we have defined thus far so do you believe engineering solutions are the way forward I think you're absolutely correct there is a range of solutions we've heard reference to complete containment but there are many different steps up to that point and accessing through is an element that we've been particularly looking at globally a colleague has recently come back from the Tasmanian project that Sam Collins referenced earlier and that is very much centred around the capturing of as much of the detritus so I think that definitely is something to be looking to the future Given that you've done that piece of work there's obviously something on your sight has anyone looked at the point that was made in the earlier session of the increased carbon footprint of moving to closed containment onshore, rearing a fish set against the environmental benefits of that approach so that's an area of work that we're looking into at the present time I made reference to SEPA's regulatory approach at a sector level for finfish farming so we are looking at all of its activities from the generation of that egg through to the production of the final product to plate part of that is assessing these new technologies and is it a substitution of another pollution problem is very much featuring in that assessment at the present time Does anybody else want to come in on those two points Mark Harvey I suppose the issue about sustainability of one environmental impact versus another depends on how sustainably Scotland's producing its electricity if it's to run on electricity for example I mean it's a relevant question it's reliant upon on other things it does seem to me that land-based containment raises a bit of a planning problem it is land hungry these would be quite large installations I don't think any planning authority could guarantee that it could immediately identify enough sites so that also raises an environmental issue I think it's suggested in the report of our member correctly that each of these sites would need its own sewage treatment plant yes that's why they're energy I mean that's technically quite feasible but of course requires energy to drive it to add in there are some early research into the use of research catchery wastes for the purposes of that future sustainability recent project that SEPA is involved with in industry and other partners around identifying sustainable uses one of those elements will be considering the detritus that falls from the bottom of the cages so there is work underway with that very aspect in mind okay I'm interested in this idea of a lander as it were going from where we are to ultimately land-based solutions there's a lot of steps in between and I think those should be investigated I must say there is a range of different products that are being trialled globally certainly discussions within the Scottish scene around the usage of them I think it is also very much locational and the flexibility around different solutions for different locations is absolutely fundamental to those conversations at the present time thank you for that thank you all of you for your evidence this morning I thank the first panel as well at its next meeting on the 20th of February the committee expects to consider a draft report on its air quality in Scotland inquiry we will now move into the private session and I ask that the public gallery is cleared as the public part of the meeting is at an end thank you