ADB modules WebUI unable to load local JavaScript ES6 modules without full trust permission
Requirements
- [x] I am using the latest version from GitHub Releases.
- [x] I am using a standard, tested ROM (no custom/untested forks).
- [x] I have searched existing issues and this is not a duplicate.
- [x] I am providing text logs, not screenshots of logs.
Shizuku Version
latest
Operation Mode
ADB Mode
Device Model & OS Version
OnePlus 10T 5G EU version
Steps to Reproduce
ES6 module scripts in module WebUI never load without Full Trust — WebUI hangs indefinitely on initial state, no error shown
Summary
A module whose webui/index.html loads its entry point with <script type="module" src="js/main.js"> (where that module in turn imports/exports other local .js files) hangs indefinitely on its initial loading state when the module does not have Full Trust. With Full Trust, it works correctly. No JavaScript error is visible in the app's console, even with an embedded console library (e.g. Eruda) active.
Root cause
In ModuleWebViewActivity.kt:
settings.allowFileAccessFromFileURLs = trusted
settings.allowUniversalAccessFromFileURLs = trusted
These two WebSettings are only enabled when the module has Full Trust (trusted = true). Unlike a regular <script src="...">, a <script type="module"> forces the Chromium engine to resolve every import as a CORS-mode fetch — even between file:// files in the same directory. Without allowFileAccessFromFileURLs / allowUniversalAccessFromFileURLs, those module-to-module requests are blocked by the WebView's same-origin policy, and the entire module graph fails to load without executing a single line of the script. That's why no application-level error appears — the failure happens at the engine's network/security layer, before any of the module's own try/catch code gets a chance to run.
How to reproduce
- Any module whose
webui/index.htmluses<script type="module" src="...">with at least oneimportto another local file. - Install it without Full Trust (Full access or Custom mode).
- Open the module's WebUI → it hangs on the initial loading state (spinner/loading message) forever.
- Grant the module Full Trust and reopen the WebUI → works normally.
Note on debugging
This isn't visible via embedded console libraries like Eruda, since they only intercept console.* calls made by application JS. A blocked module-script load is a browser/engine-level failure (CORS/security), not an application exception, so it typically only shows up in real remote DevTools (chrome://inspect over USB), not in an in-page console shim.
Proposed fix A — quick, but with a security tradeoff to consider
Decouple ES6 module loading from the Full Trust flag by enabling allowFileAccessFromFileURLs / allowUniversalAccessFromFileURLs for every enabled module, not just Full Trust ones. The downside is that allowUniversalAccessFromFileURLs in particular is a fairly broad Android setting (it lets file:// content access remote http(s) origins without the usual CORS restrictions), so enabling it for non-Full-Trust modules reduces some of the isolation the current trust model is trying to provide. This may be acceptable given the content is still locally installed by the user, but it's worth a deliberate call rather than a blind toggle.
Proposed fix B — the officially recommended approach for this exact scenario
Use androidx.webkit.WebViewAssetLoader (from the AndroidX WebKit libraries) to serve the module's webroot files through a virtual https://appassets.androidplatform.net/... origin instead of file://. This is done by intercepting WebViewClient.shouldInterceptRequest() and serving the local files under that virtual pseudo-https origin. Because the origin is then a "real" https origin (even though it's virtual and fully local), ES6 module imports work under normal CORS rules without needing allowFileAccessFromFileURLs or allowUniversalAccessFromFileURLs at all — so no existing protection needs to be weakened for non-Full-Trust modules. This is literally what the official Android WebView documentation recommends for "how to load local content (including ES6 modules) in a WebView safely": https://developer.android.com/develop/ui/views/layout/webapps/loading-webapp — see the "Handling requests to load local files" section.
Logcat / Crash Logs
No logs here.
🤖 AI Triage
The cited file ModuleWebViewActivity.kt could not be read, so this cannot be confirmed via code inspection at this time. However, the analysis of WebView CORS restrictions on ES6 modules and the proposed use of WebViewAssetLoader are technically sound.
Note: this is an automated AI bot (Gemini); its verdict isn't 100% accurate and can be wrong. The bot doesn't read or reply to further comments in this thread — if it got this wrong, ping a human maintainer.
To enable Full Trust: in the ADB Modules screen, long-press the module card and tap Trust. This will help with this problem.
A migration to WebViewAssetLoader is postponed for later and is not guaranteed (we might not switch to it at all).
@kerneldroid @HmnDev-Tech
Thanks for the quick reply! I get that a full WebViewAssetLoader migration is a bigger undertaking and I understand wanting to postpone it — but I'd like to push back a bit on "just enable Full Trust" as the recommended workaround, because it conflates two things that really shouldn't be coupled.
Full Trust is a much bigger grant than "let my JS modules load"
Per your own docs, Full Trust doesn't just relax file-URL access for the WebView — it also:
- Skips ReCommand confirmation entirely for every shell/Action execution.
- Allows background Service execution without the global background toggle.
- Allows
window.Shizukuto be exposed withoutusesShellBridge=true. - Allows WebView internet +
window.Shizukutogether, which is explicitly blocked otherwise. - Allows
download()to overwrite the WebUI entry files themselves, even when global WebUI download is blocked. - Bypasses the global Safe/Custom/Full execution policy altogether.
A developer who just wants their <script type="module"> imports to resolve on file:// has to accept all of that, for every install, forever — no confirmation prompts, unrestricted background execution, and the ability to silently rewrite their own WebUI's entry point. That's a huge trust footprint for what is fundamentally a resource-loading limitation, not a permissions decision the user is actually being asked to make. It also means every module author who wants modern JS tooling is incentivized to ask users for the single highest privilege tier available, which undermines the whole point of having a graduated trust model in the first place.
ES6 modules aren't a niche feature — they're the baseline
import/export has been supported in every major browser (Chrome, Firefox, Safari, and yes, Android WebView) since 2017–2018. It's not an edge case or a "modern JS" gamble — it's been the standard way to structure non-trivial JS for the better part of a decade, and it's what basically every current tutorial, style guide, and framework assumes you're using. Right now, any module author who wants to write more than a single flat script has two options: cram everything into one giant file with manually-ordered <script> tags and a global namespace object (a pattern most JS devs haven't written since ~2015), or require Full Trust just to use import. Neither is a great look for an ecosystem you presumably want people to keep building modules for.
This is a real barrier to new module authors
Speaking as someone actively building a module right now: this is the kind of thing that makes a WebUI "just don't bother" territory for a lot of developers, especially anyone coming from a modern JS background who reaches for ES modules by default and doesn't expect file:// CORS quirks to be a consideration at all. It's a rough surprise to hit after the WebUI already looks like it's working correctly in every other browser context (including desktop Chrome DevTools), and to only discover it's broken specifically for non-trusted installs, with zero console error to point at.
The fix genuinely doesn't have to touch your security model
This is the part I'd really like to highlight: androidx.webkit.WebViewAssetLoader isn't a rewrite of how module trust works, it's a change scoped entirely to how the WebView resolves file:// requests. You intercept shouldInterceptRequest() and serve the same local webroot files under a virtual https://appassets.androidplatform.net/... origin instead of raw file://. Because that's a "real" https origin as far as Chromium's module loader is concerned, ES6 import resolution just works under normal CORS rules — without needing allowFileAccessFromFileURLs or allowUniversalAccessFromFileURLs enabled at all, trusted or not. Nothing about Full Trust, ReCommand, background execution, or the Safe/Custom/Full policy needs to change. It's additive to ModuleWebViewActivity.kt and self-contained — it doesn't ask you to relax anything for untrusted modules, it just removes a rendering-layer limitation that was never meant to be a security boundary in the first place (allowFileAccessFromFileURLs/allowUniversalAccessFromFileURLs control resource loading, not shell/ADB access — this is a WebView plumbing quirk, not a deliberate permission gate).
If a full migration is off the table for now, would you be open to a narrower interim fix: enabling just allowFileAccessFromFileURLs/allowUniversalAccessFromFileURLs for all enabled modules (not gated on trusted) as a stopgap, while WebViewAssetLoader stays on the roadmap for later? That's a much smaller, much more targeted change — it only affects how file:// resources resolve each other, not shell execution, ReCommand, background services, or download permissions — so it doesn't erode the rest of the trust model the way requiring full Trust does. Happy to open a PR for either approach if that helps move it along.
@kerneldroid @HmnDev-Tech no consideration at all?
I may look into this in the future, but I'm not the lead maintainer and don't have time for this right now.
I will try to implement this in Nigthzuku, and if everything is stable, then we will transfer it to the Shevery. (Mayb. Also i need to talk to the main developer)
Fixed and published!
I’ve added this to nightzuku as well. The implementation seems to differ from Shevery, so compare both and let me know which one is better."