{"action":"created","issue":{"url":"https://api.github.com/repos/phonegap/phonegap-plugin-barcodescanner/issues/312","repository_url":"https://api.github.com/repos/phonegap/phonegap-plugin-barcodescanner","labels_url":"https://api.github.com/repos/phonegap/phonegap-plugin-barcodescanner/issues/312/labels{/name}","comments_url":"https://api.github.com/repos/phonegap/phonegap-plugin-barcodescanner/issues/312/comments","events_url":"https://api.github.com/repos/phonegap/phonegap-plugin-barcodescanner/issues/312/events","html_url":"https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/312","id":173318303,"number":312,"title":"Memory leak on iOS 10 devices","user":{"login":"jlowe234","id":19482405,"avatar_url":"https://avatars.githubusercontent.com/u/19482405?v=3","gravatar_id":"","url":"https://api.github.com/users/jlowe234","html_url":"https://github.com/jlowe234","followers_url":"https://api.github.com/users/jlowe234/followers","following_url":"https://api.github.com/users/jlowe234/following{/other_user}","gists_url":"https://api.github.com/users/jlowe234/gists{/gist_id}","starred_url":"https://api.github.com/users/jlowe234/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlowe234/subscriptions","organizations_url":"https://api.github.com/users/jlowe234/orgs","repos_url":"https://api.github.com/users/jlowe234/repos","events_url":"https://api.github.com/users/jlowe234/events{/privacy}","received_events_url":"https://api.github.com/users/jlowe234/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-25T21:46:54Z","updated_at":"2016-09-01T19:59:14Z","closed_at":null,"body":"There appears to be a memory leak occurring when using the scanner against iOS 10 devices.\r\n\r\nI've created the following test case that allocates/deallocates successfully on an iPad with iOS 7.1.2, but will never dealloc the scanner on iOS 10.  \r\n\r\nHere's the app that I used in my test.  Just a standard Cordova (5.3.3) + barcodescanner (6.0.1) with the following index.html.\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<!--\r\n Licensed to the Apache Software Foundation (ASF) under one\r\n or more contributor license agreements.  See the NOTICE file\r\n distributed with this work for additional information\r\n regarding copyright ownership.  The ASF licenses this file\r\n to you under the Apache License, Version 2.0 (the\r\n \"License\"); you may not use this file except in compliance\r\n with the License.  You may obtain a copy of the License at\r\n \r\n http://www.apache.org/licenses/LICENSE-2.0\r\n \r\n Unless required by applicable law or agreed to in writing,\r\n software distributed under the License is distributed on an\r\n \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\n KIND, either express or implied.  See the License for the\r\n specific language governing permissions and limitations\r\n under the License.\r\n -->\r\n<html>\r\n    <head>\r\n        <!--\r\n         Customize this policy to fit your own app's needs. For more guidance, see:\r\n         https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy\r\n         Some notes:\r\n         * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication\r\n         * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly\r\n         * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:\r\n         * Enable inline JS: add 'unsafe-inline' to default-src\r\n         -->\r\n        <!--<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self' 'unsafe-inline' data: gap: https://ssl.gstatic.com ; style-src 'self'; media-src *\">-->\r\n            <meta name=\"format-detection\" content=\"telephone=no\">\r\n                <meta name=\"msapplication-tap-highlight\" content=\"no\">\r\n                    <meta name=\"viewport\" content=\"user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width\">\r\n                        <link rel=\"stylesheet\" type=\"text/css\" href=\"css/index.css\">\r\n                            <title>Hello World</title>\r\n                            </head>\r\n    <body>\r\n        <div class=\"app\">\r\n            <script type=\"text/javascript\" src=\"cordova.js\"></script>\r\n            <script type=\"text/javascript\" src=\"js/index.js\"></script>\r\n            <script type=\"text/javascript\">\r\n                function scanTest(field) {\r\n                    try {\r\n                        var scanner = window.cordova.require(\"phonegap-plugin-barcodescanner.BarcodeScanner\");\r\n                        scanner.scan(\r\n                                     function (result) {\r\n                                     if (document.getElementById(field)) {\r\n                                     debugger;\r\n\r\n                                     document.getElementById(field).innerHTML = result.text;\r\n                                     \r\n                                     } else {\r\n                                     alert(\"field is bad\");\r\n                                     }\r\n                                     });\r\n                    } catch (e) {\r\n                        alert(\"ErrorDescription: \" + e);\r\n                    }\r\n                }\r\n            \r\n            </script>\r\n            <h1>Apache Cordova</h1>\r\n            <div id=\"deviceready\" class=\"blink\">\r\n                <p class=\"event listening\">Connecting to Device</p>\r\n                <p class=\"event received\">Device is Ready</p>\r\n                <p id=\"scan\">Test scan</p>\r\n                <a href=\"#\" onclick='scanTest(\"scan\");' id=\"scanshortcut\">Scan</a>\r\n            </div>\r\n        </div>\r\n        \r\n    </body>\r\n</html>\r\n```\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/phonegap/phonegap-plugin-barcodescanner/issues/comments/244194140","html_url":"https://github.com/phonegap/phonegap-plugin-barcodescanner/issues/312#issuecomment-244194140","issue_url":"https://api.github.com/repos/phonegap/phonegap-plugin-barcodescanner/issues/312","id":244194140,"user":{"login":"jlowe234","id":19482405,"avatar_url":"https://avatars.githubusercontent.com/u/19482405?v=3","gravatar_id":"","url":"https://api.github.com/users/jlowe234","html_url":"https://github.com/jlowe234","followers_url":"https://api.github.com/users/jlowe234/followers","following_url":"https://api.github.com/users/jlowe234/following{/other_user}","gists_url":"https://api.github.com/users/jlowe234/gists{/gist_id}","starred_url":"https://api.github.com/users/jlowe234/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlowe234/subscriptions","organizations_url":"https://api.github.com/users/jlowe234/orgs","repos_url":"https://api.github.com/users/jlowe234/repos","events_url":"https://api.github.com/users/jlowe234/events{/privacy}","received_events_url":"https://api.github.com/users/jlowe234/received_events","type":"User","site_admin":false},"created_at":"2016-09-01T19:59:14Z","updated_at":"2016-09-01T19:59:14Z","body":"I don't even get the message from the debugger with my testing.  It just crashes the connection and shows nothing.\r\n\r\nI have however found that the leak of 100 MiB per scan is tied to this line in the -setUpCaptureSession method:\r\n`    NSDictionary* videoOutputSettings = [NSDictionary\r\n                                         dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA]\r\n                                         forKey:(id)kCVPixelBufferPixelFormatTypeKey\r\n                                         ];`\r\n\r\nI removed that from the plugin and it appears to leak a good amount less than before.  The only issue that I am having difficulty with right now is understanding why this is a leak now in iOS 10, and where the 10-15 MiB leak is in the application itself.  \r\n\r\nRemoving that line has made it so that it takes about 20-30 scans before I can crash the application.  It will only seem to crash after the application leak manages to get to critical mass (highest I've gotten so far in testing is 515 MB).\r\n\r\nI believe it has something to do with the capture stream from the AVCaptureSession/AVCaptureVideoDataOutput but I just don't understand enough about what I'm looking at/into to really find the correct course.\r\n\r\nThe majority of the leaked memory seems to be dirty IOKit VM allocations that just float there forever."}}
{"actor":{"display_login":"jlowe234"}}