Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StrictMode Violations #145

Open
GPryan opened this issue Sep 14, 2018 · 3 comments
Open

StrictMode Violations #145

GPryan opened this issue Sep 14, 2018 · 3 comments

Comments

@GPryan
Copy link

GPryan commented Sep 14, 2018

We have the following StrictMode settings:

StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
    .detectDiskReads()
    .detectDiskWrites()
    .detectNetwork()
    .penaltyLog()
    .penaltyDeath()
    .build()
)
  • File Explorer, Shared Preferences, and Screen Recorder all violate the detectDiskReads() policy
  • Screen Recorder also violates the detectDiskWrites() policy
@ToxicBakery
Copy link
Contributor

ToxicBakery commented Sep 15, 2018

Those aren't violations they are detections. All of these write to disk and read from disk, they have to.

Implement Hyperion as one of your build variants that does not enable detections on the main thread.

@GPryan
Copy link
Author

GPryan commented Sep 17, 2018

Thanks @ToxicBakery , unfortunately that's not an option for us. It's still a possibility though that this library could be updated to do disk IO on a thread other than the main thread, is that right?

@ToxicBakery
Copy link
Contributor

ToxicBakery commented Sep 19, 2018

Looking at it more closely, not really. These plugins are meant to be used in dev and shifting everything to background threads isn't all that trivial. For instance, even attempting to load the plugins is a disk read violation if the thread policy is set in the application class. To support this requirement, a lot of rework would need to be done in the plugins that violate strict mode moving everything to a worker queue style implementation such as with pools or RX neither of which brings many benefits to end users and would impose requirements down on other 3rd party plugins that likely also do not concern themselves with disk reads/writes.

I understand the goals for using strict mode; however, Hyperion isn't meant to be shipped to production and StrictMode isn't meant to be law. StrictMode's only goal is to help you find potential problems. I would recommend you remove penaltyDeath() as that's rather excessive.

Lastly, why is a build variant not an option for you? This isn't the first time that claim has come up but I can't come up with a situation that would make variants not an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants