Break stuff. Now.

On Research Spikes and Developer Time

Or spending hours reading than days down the wrong path

July 3, 2023

Man Seasoning Scrambled Eggs Photo by Ketut Subiyanto from Pexels

Among the many little personal projects I'm doing, one of them sounds rather simple: detect if a specific type of resource is loaded onto a webpage. The concept is not foreign, your browser ad blocker does this all the time to detect and block ads. And this is thanks to webRequest APIs. However, once you venture into the mobile space is where things get a little muddy.

On mobile, web extensions are nowhere in sight. Chrome doesn't support it, Firefox only allows a curated list of them, and Safari (which powers all the other browsers in the iOS ecosystem) has a convoluted version of it. Also, making a GET request to the webpage's URL is not enough as this only loads the page's document. You'd have to load the webpage in a web browser environment so that it then loads the other resources on the page. Then from there, we detect what things are loaded by the page. Hopefully.

android.webkit has shouldInterceptRequest which lets you intercept all GET requests made inside a web view. However, iOS's WKWebView does not have an identical analog. This means downstream projects such as webview_flutter [1] and react-native-webview[1][2][3][4], which typically design their APIs based on the common denominator, will be missing this functionality. Working with native Android is fine for my use case, but I couldn't even get the Android emulator running without crashing and bringing down the entire OS with it.

I'm not an Android or iOS developer. I'm not a React Native or Flutter developer either. It's not that I don't want to learn them, but learning a whole new tech stack for a small problem only to find dead end after dead end with nowhere else to go but plow through is not a good use of my time. I'll take a day or two's worth of research before starting work please. Scrambled. No salt.

PS: I've taken the same approach at work, doing more "research spikes" to get a feel of what it takes to achieve something before sending off developers down an unknown path. It's a win-win, saving other developers' time while I get to learn stuff.

PPS: I got sucked into learning React Native 12 hours after this was posted. Found a way to custom-build a web view. It does require native but then realized that with some architecture sorcery, I could just stub out this portion and deal with it later.