{"id":148,"date":"2024-02-24T03:54:10","date_gmt":"2024-02-24T03:54:10","guid":{"rendered":"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/?p=148"},"modified":"2024-02-24T21:02:39","modified_gmt":"2024-02-24T21:02:39","slug":"jason-lus-status-report-for-02-24","status":"publish","type":"post","link":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/2024\/02\/24\/jason-lus-status-report-for-02-24\/","title":{"rendered":"Jason Lu&#8217;s Status Report for 02\/24"},"content":{"rendered":"<h1>This Week&#8217;s Accomplishments<\/h1>\n<ul>\n<li>Worked on design review slides<\/li>\n<li>Flashed firmware for the Pi &#8211; whatever was on the Pi originally did not want to boot<\/li>\n<li>Chose a UI framework (see below)<\/li>\n<li>Built a hello world app in Electron (see below)<\/li>\n<\/ul>\n<h1>Schedule<\/h1>\n<p>Out of the 5 targets from last week, I&#8217;ve completed 4 of them (green text).<\/p>\n<ol>\n<li><span style=\"color: #008000\">Complete the design review slides<\/span><\/li>\n<li><span style=\"color: #008000\">Get the RPi up and running<\/span><\/li>\n<li><span style=\"color: #008000\">Select a graphical framework<\/span><\/li>\n<li><span style=\"color: #008000\">Write a barebones hello world GUI application<\/span><\/li>\n<li><span style=\"color: #ff0000\">Begin UI mockup<\/span><\/li>\n<\/ol>\n<p>I originally slipped behind a bit according to the schedule as software bringup was supposed to be done by 02\/21 and I only finished it on 02\/24. Nonetheless, I am on schedule as of this moment again, although there is a risk of slipping behind a bit if I don&#8217;t finish the UI mockup by 02\/28.<\/p>\n<h1>Upcoming Deliverables<\/h1>\n<p>The main deliverables for this week are:<\/p>\n<ol>\n<li>Complete the UI mockup by 02\/28<\/li>\n<li>Start implementation of the UI in code<\/li>\n<\/ol>\n<h1>Choosing a UI framework<\/h1>\n<h2>Step 1: Options<\/h2>\n<p>I ruled out using a web app simply because we would need to interface with hardware which is more difficult with web apps. I&#8217;d need to write native code even with a web app to interface with the hardware, and trying to connect the native code and web app seems difficult to me.<\/p>\n<p>Here are some options that I first considered:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.electronjs.org\/\">Electron<\/a> &#8211; I knew of this as a cross-platform UI framework that uses Chromium under the hood<\/li>\n<li><a href=\"https:\/\/www.qt.io\/product\">Qt<\/a><\/li>\n<li><a href=\"https:\/\/www.gtk.org\/\">Gtk<\/a><\/li>\n<\/ul>\n<p>During testing, I also added a Rust framework that is conceptually similar to Electron, called <a href=\"https:\/\/tauri.app\/\">Tauri<\/a>. I&#8217;ve seen it before in my free time and I saw it again when I was browsing Rust UI frameworks at <a href=\"https:\/\/areweguiyet.com\/\">https:\/\/areweguiyet.com\/<\/a>. I chose to add it because I saw the high memory usage of Electron and wanted something conceptually similar but hopefully lower usage, and I was curious if Tauri might accomplish that.<\/p>\n<p>&nbsp;<\/p>\n<h2>Step 2: Evaluation Criteria<\/h2>\n<p>Here are the criteria that I used to evaluate things. Note that not every factor is weighted equally.<\/p>\n<ol>\n<li>Cross-platform &#8211; Can this run on both MacOS and Linux? Our RPi runs Raspbian, and I plan to primarily develop on my MacBook so if the framework is cross-platform I can work on my MacBook and build for Linux from the same code base.<\/li>\n<li>Language\/Tooling Familiarity &#8211; Given that we have limited time for developing things, I don&#8217;t want to spend too much time on learning the language primarily used for the framework nor learning how to use the framework itself.<\/li>\n<li>Adoption &#8211; Who are the major users of it? If it is a framework that is used by major apps, it means that this framework should be production-ready and is proven to be usable for real-world tasks.<\/li>\n<li>Baseline resource usage &#8211; How much CPU usage and RAM do we use rendering roughly the same things? Our Raspberry Pi 4, while it does have 8 GB RAM, at the end of the day is more of an embedded system that does not have the power of a desktop system. Spending too much resources on rendering the UI would increase power draw and take up performance that could be used for other tasks like radar data processing and collision time estimation.<\/li>\n<li>Cross-compileable &#8211; Can we easily build packages for the RPi 4 from a host computer? While technically I could build on the RPi 4, it&#8217;s easier to build on the host computer and copy the package to the RPi 4 so we don&#8217;t have to install build tools on the Pi itself. Building on a laptop is probably a lot faster too.<\/li>\n<\/ol>\n<h2>Step 3: Testing<\/h2>\n<p>I created hello world apps in all 4 frameworks and measured their memory and CPU usage. Testing was conducted on a M1 MacBook Air running MacOS Sonoma (14.2.1) with 16 GB RAM. Admittedly the laptop is much faster than an RPi 4 and isn&#8217;t even running the same OS, but I&#8217;m hoping that the general trends will be similar across MacOS and Linux.<\/p>\n<p>The memory usage was obtained by using Activity Monitor and summing up the relevant threads&#8217; memory usage (e.g., for Electron we have multiple threads running around so we need to account for all of them). For calculating CPU usage, this is admittedly a lot less scientific where I just watched the CPU usage of the threads and grabbed the maximum value (only if it repeatedly hit it &#8211; e.g., hitting 1% CPU usage just once wouldn&#8217;t count, only if it fluctuated up to 1% a few times).<\/p>\n<p>The code for all of four demo applications are in our shared Github repository.<\/p>\n<h3>Results<\/h3>\n<p><a href=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/UI-Framework-Table.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-173 size-full\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/UI-Framework-Table.png\" alt=\"\" width=\"836\" height=\"658\" srcset=\"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/UI-Framework-Table.png 836w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/UI-Framework-Table-300x236.png 300w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/UI-Framework-Table-768x604.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/a>For the full file with citations, please see the <a href=\"https:\/\/docs.google.com\/document\/d\/1aHzTlhqWZueQZs1ffh57dDll6ASmMpdW\/edit?usp=drive_link&amp;ouid=100976998417001896953&amp;rtpof=true&amp;sd=true\">file in Google Drive<\/a><\/p>\n<h3>Screenshots<\/h3>\n<p>Here are some screenshots of the hello world apps:<\/p>\n<figure id=\"attachment_168\" aria-describedby=\"caption-attachment-168\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-168 size-medium\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Electron-Hello-World-300x227.png\" alt=\"\" width=\"300\" height=\"227\" srcset=\"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Electron-Hello-World-300x227.png 300w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Electron-Hello-World-768x582.png 768w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Electron-Hello-World.png 818w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-168\" class=\"wp-caption-text\">&#8220;Hello world&#8221; using Electron<\/figcaption><\/figure>\n<figure id=\"attachment_169\" aria-describedby=\"caption-attachment-169\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-169 size-medium\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/QT-Hello-World-300x243.png\" alt=\"\" width=\"300\" height=\"243\" srcset=\"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/QT-Hello-World-300x243.png 300w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/QT-Hello-World-768x623.png 768w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/QT-Hello-World.png 912w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-169\" class=\"wp-caption-text\">&#8220;Hello world&#8221; using QT<\/figcaption><\/figure>\n<figure id=\"attachment_170\" aria-describedby=\"caption-attachment-170\" style=\"width: 227px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-170 size-full\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/GTK-Hello-World.png\" alt=\"\" width=\"227\" height=\"251\" \/><figcaption id=\"caption-attachment-170\" class=\"wp-caption-text\">&#8220;Hello world&#8221; using GTK<\/figcaption><\/figure>\n<figure id=\"attachment_167\" aria-describedby=\"caption-attachment-167\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-167 size-medium\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Tauri-Hello-World-300x226.png\" alt=\"\" width=\"300\" height=\"226\" srcset=\"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Tauri-Hello-World-300x226.png 300w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Tauri-Hello-World-768x579.png 768w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Tauri-Hello-World.png 817w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><figcaption id=\"caption-attachment-167\" class=\"wp-caption-text\">&#8220;Hello world&#8221; using Tauri<\/figcaption><\/figure>\n<h2>Step 4: Decision<\/h2>\n<p>All four frameworks are cross-platform so we can ignore that as a deciding factor, although if one of them wasn&#8217;t it would have been a major negative point.<\/p>\n<p>For Tauri, I was unfortunately unable to find any applications that I knew of that used it, which made me a little more hesitant about whether it would be as production-ready and usable for real-world apps as the other three. Therefore, I ruled out considering it further.<\/p>\n<p>Between Qt, Gtk, and Electron, Qt and Gtk have similar performance requirements. Sadly, Electron uses 5x the memory and has a little bit more measurable overhead.<\/p>\n<p>However, I feel much more comfortable with using HTML\/CSS\/JavaScript for building UIs since I&#8217;ve used them before for web development. In contrast, I&#8217;m not as familiar with how to build UIs with Qt and Gtk (either through code or the <a href=\"https:\/\/docs.gtk.org\/gtk4\/getting_started.html#building-applications\">GtkBuilder system<\/a>) which would take additional time to become familiar with. I also was not familiar with Qt&#8217;s tooling such as Qt Creator (although apparently it isn&#8217;t required, just recommended), so learning that would incur some additional time expense. Language-wise, I feel more comfortable with Javascript\/HTML\/CSS or C vs. C++. So overall, I feel a lot more comfortable using Electron compared to the other two due to the smaller learning curve.<\/p>\n<p>So in the end, it is a tradeoff between performance overhead and ease-of-development.<\/p>\n<p>Given that consideration, I&#8217;d rather use Electron despite the performance overhead simply because the lower learning curve is more important to me. The memory usage, despite being 5x as much, shouldn&#8217;t be an issue on the Pi when we have 8 GB (although it will make it more difficult to downsize to a board with less RAM). The fact that Electron can be easily packaged for Linux from MacOS is a bonus whereas packaging the other two from MacOS will be harder (see references).<\/p>\n<p><strong>DECISION: Use Electron for the framework<\/strong><\/p>\n<h1>Building a Hello World App<\/h1>\n<h2>Scaffolding<\/h2>\n<p>First, I had to scaffold a basic Electron app. Based on the <a href=\"https:\/\/www.electronjs.org\/docs\/latest\/tutorial\/tutorial-prerequisites\">Electron tutorial<\/a> which mentioned the create-electron-app command, I decided to use that so I didn&#8217;t have to spend time on boilerplate stuff.<\/p>\n<p>Reading the <a href=\"https:\/\/www.electronforge.io\/\">documentation<\/a> for create-electron-app, I saw I had a choice between Webpack and Vite-based templates. I&#8217;ve used Webpack in the past but Vite was completely unfamiliar to me, but based on <a href=\"https:\/\/vitejs.dev\/guide\/why\">https:\/\/vitejs.dev\/guide\/why<\/a> and\u00a0<a href=\"https:\/\/blog.replit.com\/vite\">https:\/\/blog.replit.com\/vite<\/a> it seems like it does the job of Webpack (<a href=\"https:\/\/news.ycombinator.com\/item?id=26972400\">although not all of it<\/a>) so I&#8217;ll go with that. TypeScript is nice because it gives us typing information, so I&#8217;ll use the vite-typescript template.<\/p>\n<p>The final scaffolding commandline was:<\/p>\n<p><code>npm init electron-app@latest ui -- --template=vite-typescript<\/code><\/p>\n<p>Here&#8217;s a screenshot of the app:<\/p>\n<figure id=\"attachment_193\" aria-describedby=\"caption-attachment-193\" style=\"width: 819px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-193\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Electron-Hello-World-Final.png\" alt=\"\" width=\"819\" height=\"615\" srcset=\"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Electron-Hello-World-Final.png 819w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Electron-Hello-World-Final-300x225.png 300w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/Electron-Hello-World-Final-768x577.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption id=\"caption-attachment-193\" class=\"wp-caption-text\">Screenshot of the app that was generated using create-electron-app<\/figcaption><\/figure>\n<h2>Testing Packaging<\/h2>\n<p>I also wanted to see if I could package this for a Linux system. I spun up an ARM Linux image on my computer (using <a href=\"https:\/\/getutm.app\/\">UTM<\/a> and the <a href=\"https:\/\/mac.getutm.app\/gallery\/debian-12\">Debian 12 image from UTM<\/a>), and built a .deb package for Debian using electron-forge. After installing it, I verified I can build packages for Linux from my Mac and have it run!<\/p>\n<figure id=\"attachment_194\" aria-describedby=\"caption-attachment-194\" style=\"width: 525px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"size-large wp-image-194\" src=\"http:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/BikeBuddy-on-Linux-1024x844.png\" alt=\"\" width=\"525\" height=\"433\" srcset=\"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/BikeBuddy-on-Linux-1024x844.png 1024w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/BikeBuddy-on-Linux-300x247.png 300w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/BikeBuddy-on-Linux-768x633.png 768w, https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-content\/uploads\/sites\/270\/2024\/02\/BikeBuddy-on-Linux.png 1296w\" sizes=\"(max-width: 525px) 100vw, 525px\" \/><figcaption id=\"caption-attachment-194\" class=\"wp-caption-text\">A screenshot of BikeBuddy packaged on MacOS running in a Linux VM<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>This Week&#8217;s Accomplishments Worked on design review slides Flashed firmware for the Pi &#8211; whatever was on the Pi originally did not want to boot Chose a UI framework (see below) Built a hello world app in Electron (see below) Schedule Out of the 5 targets from last week, I&#8217;ve completed 4 of them (green &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/2024\/02\/24\/jason-lus-status-report-for-02-24\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Jason Lu&#8217;s Status Report for 02\/24&#8221;<\/span><\/a><\/p>\n","protected":false},"author":816,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[7],"_links":{"self":[{"href":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-json\/wp\/v2\/posts\/148"}],"collection":[{"href":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-json\/wp\/v2\/users\/816"}],"replies":[{"embeddable":true,"href":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-json\/wp\/v2\/comments?post=148"}],"version-history":[{"count":28,"href":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-json\/wp\/v2\/posts\/148\/revisions"}],"predecessor-version":[{"id":197,"href":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-json\/wp\/v2\/posts\/148\/revisions\/197"}],"wp:attachment":[{"href":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-json\/wp\/v2\/media?parent=148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-json\/wp\/v2\/categories?post=148"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/course.ece.cmu.edu\/~ece500\/projects\/s24-teama3\/wp-json\/wp\/v2\/tags?post=148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}