<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ekko1500</title>
    <description>The latest articles on DEV Community by ekko1500 (@ekko1500).</description>
    <link>https://dev.to/ekko1500</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1470782%2Ffcfeafb9-6527-4b83-9b2b-504e65546521.png</url>
      <title>DEV Community: ekko1500</title>
      <link>https://dev.to/ekko1500</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ekko1500"/>
    <language>en</language>
    <item>
      <title>Debugging Android Backdrop Persistence: A Capacitor Story</title>
      <dc:creator>ekko1500</dc:creator>
      <pubDate>Mon, 30 Mar 2026 16:39:01 +0000</pubDate>
      <link>https://dev.to/ekko1500/debugging-android-backdrop-persistence-a-capacitor-story-10o5</link>
      <guid>https://dev.to/ekko1500/debugging-android-backdrop-persistence-a-capacitor-story-10o5</guid>
      <description>&lt;p&gt;Porting a complex React app like Scratch-GUI to mobile using Capacitor can surface bugs that don't appear on desktop. Recently, we fixed a frustrating issue: backdrop edits (drawings and erasures) weren't saving in &lt;code&gt;.sb3&lt;/code&gt; files on Android.&lt;/p&gt;

&lt;p&gt;Here's what went wrong and how we fixed it.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. The Main Problem: Edits Weren't Saving
&lt;/h3&gt;

&lt;p&gt;Two issues caused backdrop changes to disappear when saving.&lt;/p&gt;

&lt;h4&gt;
  
  
  A. Storage Configuration Typo
&lt;/h4&gt;

&lt;p&gt;In &lt;code&gt;storage.js&lt;/code&gt;, we had a typo in the asset storage config. It was trying to use invalid "create" and "update" helpers, triggering failed network requests in the Capacitor environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Corrected the typo and simplified &lt;code&gt;addWebStore&lt;/code&gt; to only use the GET helper for local assets.&lt;/p&gt;

&lt;h4&gt;
  
  
  B. Save Button Didn't Commit Pending Edits
&lt;/h4&gt;

&lt;p&gt;The Paint Editor (from scratch-paint) normally saves changes when you click away from the canvas. On Android, clicking the "Save" button didn't trigger that "focus lost" event, so the latest drawing wasn't being saved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Added a manual sync step before saving — calling &lt;code&gt;document.activeElement.blur()&lt;/code&gt; and waiting 100ms to ensure all edits were committed.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. The reader.addEventListener Error
&lt;/h3&gt;

&lt;p&gt;We hit a strange error: &lt;code&gt;TypeError: reader.addEventListener is not a function&lt;/code&gt; — and it only appeared on Android.&lt;/p&gt;

&lt;p&gt;It turns out that in some environments, &lt;code&gt;FileReader&lt;/code&gt; doesn't fully support &lt;code&gt;addEventListener&lt;/code&gt;. It only has &lt;code&gt;onload&lt;/code&gt; and &lt;code&gt;onerror&lt;/code&gt; callbacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Added a lightweight polyfill at app startup that adds &lt;code&gt;addEventListener&lt;/code&gt; support to &lt;code&gt;FileReader.prototype&lt;/code&gt;, mapping it to the existing handler properties.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Canvas Performance Warning
&lt;/h3&gt;

&lt;p&gt;Android's WebView kept showing this warning:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Canvas2D: Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This happens when the canvas is read often — like in Scratch's "touching color" blocks and paint editor fill tools.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Updated all &lt;code&gt;getContext('2d')&lt;/code&gt; calls (in the loupe, video provider, and costume display) to include &lt;code&gt;{ willReadFrequently: true }&lt;/code&gt;. This tells the browser to optimize for frequent reads, making things much faster.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Touch Scrolling Felt Laggy
&lt;/h3&gt;

&lt;p&gt;Chrome and WebView warn when non-passive event listeners are used on scroll-blocking events like &lt;code&gt;touchstart&lt;/code&gt;. This can make scrolling feel sluggish.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Updated global touch handlers to use &lt;code&gt;{ passive: true }&lt;/code&gt;, letting the browser scroll immediately without waiting for JavaScript.&lt;/p&gt;




&lt;h3&gt;
  
  
  What We Learned
&lt;/h3&gt;

&lt;p&gt;Cross-platform development isn't just about writing code — it's about understanding the subtle differences in runtime environments. A standard browser API like &lt;code&gt;FileReader&lt;/code&gt; or Canvas2D can behave slightly differently in a WebView than in a desktop browser, and those differences can cause major issues in complex apps.&lt;/p&gt;

&lt;p&gt;Key takeaway: Make sure your "save" logic works reliably across all input types (touch, mouse, keyboard), and don't hesitate to polyfill environment gaps to keep your libraries happy.&lt;/p&gt;




</description>
      <category>android</category>
      <category>javascript</category>
      <category>mobile</category>
      <category>react</category>
    </item>
    <item>
      <title>How I Solved Slow Page Loading Using the N+1 Query Fix (React + Laravel)</title>
      <dc:creator>ekko1500</dc:creator>
      <pubDate>Mon, 30 Mar 2026 06:24:46 +0000</pubDate>
      <link>https://dev.to/ekko1500/how-i-solved-slow-page-loading-using-the-n1-query-fix-react-laravel-5g92</link>
      <guid>https://dev.to/ekko1500/how-i-solved-slow-page-loading-using-the-n1-query-fix-react-laravel-5g92</guid>
      <description>&lt;p&gt;When I first built my React + Laravel application, everything worked fine—until the data started growing.&lt;/p&gt;

&lt;p&gt;Pages that used to load instantly began taking seconds. Then even longer.&lt;/p&gt;

&lt;p&gt;At first, I thought it was a frontend issue. Maybe React was re-rendering too much. Maybe my components weren’t optimized.&lt;/p&gt;

&lt;p&gt;I was wrong.&lt;/p&gt;

&lt;p&gt;The real problem was happening in the backend—and it had a name: the &lt;strong&gt;N+1 query problem&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem I Didn’t See at First
&lt;/h2&gt;

&lt;p&gt;Let’s say I had something like this in my Laravel backend:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A list of students&lt;/li&gt;
&lt;li&gt;Each student has marks&lt;/li&gt;
&lt;li&gt;Each mark belongs to a subject&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Simple, right?&lt;/p&gt;

&lt;p&gt;But here’s what actually happened when I fetched data:&lt;/p&gt;

&lt;p&gt;1 query to get students&lt;br&gt;
Then &lt;strong&gt;N queries&lt;/strong&gt; to get each student's related data&lt;/p&gt;

&lt;p&gt;So if I had 100 students, I was running:&lt;br&gt;
👉 &lt;strong&gt;101 queries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That’s the N+1 problem.&lt;/p&gt;

&lt;p&gt;And it destroyed performance.&lt;/p&gt;


&lt;h2&gt;
  
  
  How I Discovered It
&lt;/h2&gt;

&lt;p&gt;I started debugging the backend and noticed something strange:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The API response time was slow&lt;/li&gt;
&lt;li&gt;Database queries were increasing with data size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I used Laravel debugging tools and logs.&lt;/p&gt;

&lt;p&gt;That’s when I saw it clearly:&lt;br&gt;
👉 Queries were being executed inside loops&lt;/p&gt;

&lt;p&gt;That’s the moment it clicked.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Fix: Eager Loading
&lt;/h2&gt;

&lt;p&gt;Laravel already has a solution for this: &lt;strong&gt;Eager Loading&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of fetching related data one-by-one, I loaded everything in a single query.&lt;/p&gt;
&lt;h3&gt;
  
  
  Before (Bad)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$students&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;all&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$students&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nv"&gt;$student&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$student&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;marks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// triggers query every time&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  After (Good)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$students&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'marks'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only &lt;strong&gt;2 queries total&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;No matter how many students&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Massive improvement.&lt;/p&gt;


&lt;h2&gt;
  
  
  Going Deeper: Nested Relationships
&lt;/h2&gt;

&lt;p&gt;My case wasn’t that simple.&lt;/p&gt;

&lt;p&gt;I had deeper relationships like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;students → marks → subjects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I used nested eager loading:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$students&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Student&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'marks.subject'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now everything loads efficiently in minimal queries.&lt;/p&gt;




&lt;h2&gt;
  
  
  Optimizing the API Response
&lt;/h2&gt;

&lt;p&gt;Fixing queries wasn’t enough.&lt;/p&gt;

&lt;p&gt;I also improved how data was sent to React.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I changed:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Removed unnecessary fields&lt;/li&gt;
&lt;li&gt;Used API Resources (Transformers)&lt;/li&gt;
&lt;li&gt;Sent only what the UI actually needs
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;StudentResource&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$students&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This reduced payload size and improved speed.&lt;/p&gt;




&lt;h2&gt;
  
  
  React Side Optimization
&lt;/h2&gt;

&lt;p&gt;After fixing Laravel, I improved React too.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Avoid Unnecessary Re-renders
&lt;/h3&gt;

&lt;p&gt;I used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;useMemo&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;useCallback&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Proper state structure&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Lazy Loading Components
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Dashboard&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./Dashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This reduced initial load time.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Efficient Data Fetching
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Avoided duplicate API calls&lt;/li&gt;
&lt;li&gt;Cached results when possible&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Result
&lt;/h2&gt;

&lt;p&gt;After all optimizations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Page load time dropped significantly&lt;/li&gt;
&lt;li&gt;API became faster and more scalable&lt;/li&gt;
&lt;li&gt;UI felt instant even with large data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What used to feel slow and heavy became smooth and responsive.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;This experience taught me something important:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Performance problems are often not where you think they are.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I spent time looking at React—but the real issue was in the database.&lt;/p&gt;




&lt;h2&gt;
  
  
  Key Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Always watch for &lt;strong&gt;N+1 queries&lt;/strong&gt; in backend systems&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;Eager Loading&lt;/strong&gt; in Laravel (&lt;code&gt;with()&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Optimize API responses, not just queries&lt;/li&gt;
&lt;li&gt;Frontend performance depends on backend efficiency&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Fixing the N+1 query problem completely changed how I think about building applications.&lt;/p&gt;

&lt;p&gt;Now, whenever I design a feature, I ask:&lt;/p&gt;

&lt;p&gt;👉 &lt;em&gt;How many queries will this run?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Because performance isn’t just about code—it’s about how systems interact.&lt;/p&gt;

&lt;p&gt;And once you fix the root problem, everything becomes faster.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>laravel</category>
      <category>php</category>
    </item>
  </channel>
</rss>
