wingman-jr-addon / wingman_jr

This is the official repository (https://github.com/wingman-jr-addon/wingman_jr) for the Wingman Jr. Firefox addon, which filters NSFW images in the browser fully client-side: https://addons.mozilla.org/en-US/firefox/addon/wingman-jr-filter/ Optional DNS-blocking using Cloudflare's 1.1.1.1 for families! Also, check out the blog!
https://wingman-jr.blogspot.com/
Other
35 stars 6 forks source link

Test page keeps reopening on Android #164

Closed maciozo closed 2 years ago

maciozo commented 2 years ago

While this extension does work on Android, the test page that normally gets hidden on desktop, doesn't seem to work properly.

The tab itself doesn't get hidden. I assume Firefox for Android just doesn't support hidden tabs.

Usually, opening the app after leaving it for a little while will cause another test page to spawn. Sometimes, test pages will just spawn while using the Firefox app, even if there are already test pages open.

If it's not possible to get them working reliably on Android, then maybe an option to disable the test pages would be reasonable?

I understand that this extension likely wasn't designed with Android in mind, but it seems to work well apart from this issue :)

wingman-jr-addon commented 2 years ago

Greetings! You're right - it hasn't particularly been designed for Android, and I don't have it set as a supported option. Earlier 1.x versions actually didn't use the test page, but unfortunately something on Firefox + Windows for some platforms caused the GPU acceleration to break on a Firefox update. Overnight I lost a good chunk of happy users because the addon literally caused all their loads to be terrible. So, I had to create the 2.x architecture, where the background.js context is the "server" and the test pages are "clients" and the server sends work to the clients for processing. The advantage here was that the test pages did properly handle WebGL acceleration, so everything could work performantly again.

Unfortunately, as you can see by now, you can't just "disable" the test page - it is literally what does the work. You could perhaps try going back to the latest 1.x version, but you'll be missing other features and improvements. The fact that tabs are reopening may indicate something is going wrong. If you're feeling adventurous, you could try "inspect"'ing the addon and getting a dump of any errors that might be occurring. There's a watchdog that will respawn pages if they die, so it could be something around that. If you don't see anything and you're feeling particularly adventurous, you could additionally try executing bkSetAllLogging(true) after the plugin has loaded and it will show all the logs - maybe something will pop up there. One last thing that might be worth a shot too is to use the WASM backend and see if stability improves.

Not sure what else to try, but maybe the logs would turn up something.

wingman-jr-addon commented 2 years ago

@maciozo Any further thoughts or logs? Without a clear path here, I might close this for now since I don't support Firefox for Android. 🤔

maciozo commented 2 years ago

I'll see if I can experiment a bit over the weekend.

maciozo commented 2 years ago

I think I'll close this for now. The add-on does technically work, as I said earlier, but I also realised that it's obliterating my batterly life, so just isn't really practical for me anyway.

Thanks for you input anyway though, I might pick this up again when I have a better phone.

wingman-jr-addon commented 2 years ago

@maciozo Hey thanks for taking a look at this. Yes, this is not a battery friendly addon by any means - all that machine learning/AI work takes a ton of computation. Maybe a "lite" version would make sense, but I think that it would still suck battery and I'd probably have to make some tradeoffs on the model's scanning power that would be too detrimental. :(

maciozo commented 2 years ago

No worries. I actually had a thought, that maybe the heavy processing could be offloaded to a server with a decent GPU.

wingman-jr-addon commented 2 years ago

@maciozo Interesting you should mention that. For the addon, I have not wanted to do that because the self-contained privacy aspect is an important feature and I don't want to maintain a server, BUT ... I have also kicked around the idea of trying to make a basic wireless router that does the scanning using some proper hardware you could run in your own home. That might not cover a cellular case, but could cover connections on the LAN. Are you trying to scan more on the go? Or mostly at home, but your phone happens to be the client of choice?

maciozo commented 2 years ago

I think that's similar what I had in mind. It could cover cellular usage as well, if the "router" has a VPN server that your phone could route its traffic through.

I was thinking something along the lines of:

  1. Device with addon requests webpage with images
  2. Every webpage request is intercepted (like wingman jr does), and the URL is sent to a remote wingman processor (could be self-hosted to avoid privacy issues)
  3. Server responds with (N)SFW rating
  4. Server caches image hash and rating to avoid processing it again, only flushing if the model is updated

An issue with this, however, is if the website doesn't send the same image to both the device and the wingman processor. Could be mitigated by getting the device to send the image to the processor, but that would likely slow things down significantly, and increase data usage.

You could go a bit further with the VPN method, I think. If you somehow set it up so that TLS connections with websites or whatever were made by the VPN, rather than the device, then you could scan pretty much all web traffic, not just limited to web browsers.

Are you trying to scan more on the go? Or mostly at home, but your phone happens to be the client of choice?

I'd mostly use it at home, I think, but there are times when I'm tired and CBA to get on the PC.