<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lasitha Ishan Petthawadu on Medium]]></title>
        <description><![CDATA[Stories by Lasitha Ishan Petthawadu on Medium]]></description>
        <link>https://medium.com/@lasitha_ishan?source=rss-49aede15ecee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*LjRy7fLRPTVCb-aw.</url>
            <title>Stories by Lasitha Ishan Petthawadu on Medium</title>
            <link>https://medium.com/@lasitha_ishan?source=rss-49aede15ecee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 03:28:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lasitha_ishan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automating a React-native Mobile Application for Beta Testing]]></title>
            <link>https://medium.com/@lasitha_ishan/automating-a-react-native-mobile-application-for-beta-testing-bfd3eb729438?source=rss-49aede15ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfd3eb729438</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Lasitha Ishan Petthawadu]]></dc:creator>
            <pubDate>Thu, 05 Jan 2017 01:23:47 GMT</pubDate>
            <atom:updated>2018-05-30T06:05:11.378Z</atom:updated>
            <content:encoded><![CDATA[<p>This post focuses on automation and deployment of a react-native application for beta testing from a continuous integration environment.</p><p>My workflow includes the following tools</p><p>1. Jenkins for triggering the build automation. 2. Docker for containerizing and building,unit testing and deploying.</p><p>3. TestFairy for uploading the build for beta testing.</p><blockquote>Testfairy is a beta testing platform (<a href="https://testfairy.com/">TestFairy</a>) where developers and testers can collaborate for mobile testing.</blockquote><p>There are many ways of setting up the above workflow. However I would be outlining the approach that I followed, but I would try to highlight on alternative ways for each step to keep the options open for those of you who are reading.</p><p>The diagram below highlights the workflow and the flow of the data from the point of extraction from a source repository to deployment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/0*nDxhotUypebkwtZA." /></figure><h3>Usage of Jenkins</h3><p>Jenkins is responsible for fetching the source from the source repository triggering the react-native build in a containarized fashion.<br> Uploading the final build to test fairy could have been done via the Jenkins test fairy plugin (<a href="https://wiki.jenkins-ci.org/display/JENKINS/TestFairy+Plugin">https://wiki.jenkins-ci.org/display/JENKINS/TestFairy+Plugin</a>).</p><p>But I didn’t go ahead with this approach since the TestFairy plugin requires the <em>zipAlign</em> tool to be present, which is found with the <em>Android SDK</em>. However in my current setup Jenkins itself is running within a docker container and I didn’t want to clutter it up with additional dependencies like the <em>Android SDK</em>. Also I wanted a way to trigger TestFairy deployments during development time as well. All of the directed us towards the TestFairy Gradle plugin since Gradle was already part of our build system and we use it during development time for the react-native application.</p><pre>sudo chmod 777 ./android/gradlew sudo docker rm -f container-client-build || true </pre><pre>sudo docker build -t container/client -f Dockerfile . </pre><pre>sudo docker run -v /home/centos/jenkins/workspace/container-client/DeployToTestFairy/build:/mobile/android/app/build --rm --name container-client-build container/client</pre><h3>Usage of Docker</h3><p>Docker was used to sandbox and build the react-native application. I made sure the image built for the containers are immutable, so that if the built image is tagged, it has all the required source code packaged so that a build could be repeated. The container did not depend on any external configuration but exposed the build artifact through an external volume mounted to the container.</p><p>The docker image I created was based off of <a href="https://hub.docker.com/r/lovato/react-native-android/">https://hub.docker.com/r/lovato/react-native-android/</a></p><p>This image sets up the following.</p><p>1. Java Open JDK 1.8 2. Android SDK 2.3 3. Gradle 2.4 4. NPM</p><p>5. React-native CLI (I know this is overkill! I’m not going to use it for development but based off of it since I couldn’t find anything with the above configuration.)</p><p>The Dockerfile is simple and executes a few commands.</p><pre>FROM lovato/react-native-android <br>MAINTAINER Lasitha Petthawadu <br>RUN mkdir /mobile COPY . /mobile <br>WORKDIR /mobile <br>RUN chmod 775 -R *.* <br>RUN npm install <br>RUN cd /mobile/android &amp;&amp; chmod 775 gradlew <br>WORKDIR /mobile/android <br>RUN gradle clean CMD [&quot;gradle&quot;, &quot;testfairyRelease&quot;,&quot;--stacktrace&quot;]</pre><p>First during build time the image packages the source code, installs the npm dependencies needed for the application.<br> Once that is done the entry point for the container execution is set to trigger the TestFairy deployment.</p><p>I will fill in the Test fairy Gradle configuration in the next section but its quite self explanatory and the TestFairy documentation was quite sufficient enough to get a stab at it from the start.</p><h3>Gradle Testfairy Plugin</h3><p>The final piece of the puzzle was to set up the Gradle TestFairy plugin. The Testfairy Gradle plugin is based on the TestFairy Uploader API and it provides all of the configuration and is upto date and inline with it.</p><p>The Gradle configuration is quite straightforward. Adding the TestFairy Gradle plugin to the dependencies and applying the plugin in the Build.gradle, gets the plugin included in the build system.</p><p>However as I explained before the plugin configuration needs to be added to the android configuration section of the module build.gradle file.</p><p>The configuration that could be tweaked is as below.</p><pre>android { <br>  compileSdkVersion 23 <br>  buildToolsVersion &quot;23.0.1&quot; <br>  defaultConfig { <br>    applicationId &quot;...&quot; <br>    minSdkVersion 16 <br>    targetSdkVersion 22 <br>    versionCode 1 <br>    versionName &quot;0.0.0.02&quot; <br>    ndk { <br>      abiFilters &quot;armeabi-v7a&quot;, &quot;x86&quot; <br>    } <br>} <br>testfairyConfig { <br>  apiKey &quot;...&quot; testersGroups &quot;dev&quot; notify true autoUpdate false <br>}</pre><p>The official documentation <a href="https://github.com/testfairy/testfairy-gradle-plugin">here</a> would be an updated reflection of the configuration than what is presented in this blog. To get the API key for uploading the builds to test fairy you could login to your Testfairy account and navigate to the <em>Account Preferences</em> and copy the <em>Upload API key</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/0*-sU6jaUq8WxbFQ4G." /></figure><p>However, one of the gotchas I had was, when I wanted to notify the testers once a build is uploaded. However, even after setting the “notify true” property, the notification mail never reached any of the testers.<br> Later on, I discovered that the issue was due to not having tester groups and I had to specify “all” as the testerGroups to get the notification mail across. This though documented in the TestFairy Uploader API was quite cryptic and didn’t catch my mind during the first read through of it.</p><h3>Alternative Approaches</h3><p>Well, this explains how I approached it and got my builds deployed. However if you want to keep the setup simple you could always use only the Jenkins environment with the TestFairy Jenkins Plugin and all the build tools deployed within the CI environment. But the reasons above made me move ahead with the approach explained here.<br> There are also other integration methods available you could check then out at the <a href="https://docs.testfairy.com/index.html">TestFairy API Documentation</a></p><p><em>Originally published at </em><a href="https://lasithapetthawadu.wordpress.com/2017/01/05/automating-a-react-native-mobile-application-for-beta-testing/"><em>lasithapetthawadu.wordpress.com</em></a><em> on January 5, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfd3eb729438" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Page Visibility API, Making sure its seen!]]></title>
            <link>https://medium.com/@lasitha_ishan/page-visibility-api-making-sure-its-seen-d879a5ecbe1?source=rss-49aede15ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/d879a5ecbe1</guid>
            <category><![CDATA[html5]]></category>
            <category><![CDATA[page-visibility]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Lasitha Ishan Petthawadu]]></dc:creator>
            <pubDate>Tue, 17 Feb 2015 09:04:02 GMT</pubDate>
            <atom:updated>2018-06-02T11:59:44.412Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently in one of our applications, we noticed sluggish response times and crashes of a real-time SVG graph. This issue happened only when the graph was running in the background in an inactive tab of the browser window and then when brought back to front after a considerable amount of time.</p><p>During the search for a solution, we came across the following.</p><p><a href="http://stackoverflow.com/questions/13408597/chrome-tab-crashing-hanging-after-brought-on-foreground-being-long-time-on-bac">http://stackoverflow.com/questions/13408597/chrome-tab-crashing-hanging-after-brought-on-foreground-being-long-time-on-bac</a></p><p>Though the problem was clear to us that the browser suspended all rendering and immediately when switching tabs queued rendering operations took a toll on the browser window making it to crash.<br> Since there were multiple timers running in the background to render the chart, we planned on suspending the timers which render the graph when the tab is inactive thus allowing less resource usage when resuming.</p><p>In order to do this we made use of the Page Visibility API which is an HTML5 feature introduced into browsers. By consuming the Page Visibility API we made sure that the graph is rendered only when the browser tab is active and when the page is visible to the user.</p><h3>Looking into the Page Visibility API</h3><p>The page visibility API supports the following functionality.</p><p>Document.hidden maintains the state whether the page is</p><p>Returns a string denoting the visibility state of the document. Possible values:</p><p><strong>visible :</strong>This means that the page is the foreground tab of a non-minimized window.</p><p><strong>hidden :</strong> the page content is not visible to the user. The document is either a background tab or part of a minimized window, or the OS screen lock is active.</p><p><strong>prerender :</strong> the page content is being prerendered and is not visible to the user (considered hidden for purposes of document.hidden). The document may start in this state, but will never transition to it from another value. Note: browser support is optional.</p><p><strong>unloaded :</strong> the page is being unloaded from memory. Note: browser support is optional.</p><p>A simple event, fired at the document object immediately after document.visibilityState transitions between visibility states.</p><p>Note that visibility has nothing to do with whether the document’s contents have fully loaded, which implies that for any given visibility transition event, onload may or may not have already fired. In addition, visibilitychange will not fire at all if the page is opened in the foreground and is not prerendered.</p><h3>Browser Compatibility</h3><p><strong>Browser</strong> <strong>Version</strong> Chrome 13<br>33 Firefox 10<br>18 Internet Explorer 10 Opera 12.10 Safari (Webkit) 7</p><h3>Other Usages</h3><ul><li>Pausing a video/carousel when the user switches a tab.<br><a href="http://daniemon.com/tech/webapps/page-visibility/">Example application</a></li><li>Eliminating resource consuming background operations, when the user is not interacting with the web page.</li></ul><h3>References</h3><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/Guide/User_experience/Using_the_Page_Visibility_API">Using the Page Visibility API</a></li><li><a href="https://gist.github.com/Swaagie/6221897">Addy Osmani’s Cross-browser Page Visibility API poly fill</a></li></ul><p><em>Originally published at </em><a href="https://lasithapetthawadu.wordpress.com/2015/02/17/page-visibility-api/"><em>lasithapetthawadu.wordpress.com</em></a><em> on February 17, 2015.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d879a5ecbe1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>