Closed Bug 1402541 Opened 7 years ago Closed 3 years ago

StrictMode violations while updating top site titles in Activity Stream

Categories

(Firefox for Android Graveyard :: Activity Stream, defect, P3)

defect

Tracking

(fennec+)

RESOLVED INCOMPLETE
Tracking Status
fennec + ---

People

(Reporter: Grisha, Unassigned)

References

Details

Seems like use of the PRNG is triggering StrictMode violations. This seems to happen very often while we're syncing history in the background, for example.

D/StrictMode(11819): StrictMode policy violation; ~duration=275 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=543 violation=2
D/StrictMode(11819): 	at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1107)
D/StrictMode(11819): 	at libcore.io.BlockGuardOs.read(BlockGuardOs.java:148)
D/StrictMode(11819): 	at libcore.io.IoBridge.read(IoBridge.java:432)
D/StrictMode(11819): 	at java.io.FileInputStream.read(FileInputStream.java:179)
D/StrictMode(11819): 	at libcore.io.Streams.readFully(Streams.java:81)
D/StrictMode(11819): 	at java.io.DataInputStream.readFully(DataInputStream.java:120)
D/StrictMode(11819): 	at java.io.DataInputStream.readFully(DataInputStream.java:116)
D/StrictMode(11819): 	at org.mozilla.gecko.util.PRNGFixes$LinuxPRNGSecureRandom.engineNextBytes(PRNGFixes.java:243)
D/StrictMode(11819): 	at java.security.SecureRandom.nextBytes(SecureRandom.java:273)
D/StrictMode(11819): 	at java.util.UUID.randomUUID(UUID.java:130)
D/StrictMode(11819): 	at org.mozilla.gecko.activitystream.homepanel.topsites.TopSitesCard$UpdateCardTitleAsyncTask.<init>(TopSitesCard.java:190)
D/StrictMode(11819): 	at org.mozilla.gecko.activitystream.homepanel.topsites.TopSitesCard.setTopSiteTitle(TopSitesCard.java:155)
D/StrictMode(11819): 	at org.mozilla.gecko.activitystream.homepanel.topsites.TopSitesCard.bind(TopSitesCard.java:118)
D/StrictMode(11819): 	at org.mozilla.gecko.activitystream.homepanel.topsites.TopSitesPageAdapter.onBindViewHolder(TopSitesPageAdapter.java:90)
D/StrictMode(11819): 	at org.mozilla.gecko.activitystream.homepanel.topsites.TopSitesPageAdapter.onBindViewHolder(TopSitesPageAdapter.java:29)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:5471)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:5504)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4741)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4617)
D/StrictMode(11819): 	at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:1994)
D/StrictMode(11819): 	at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:528)
D/StrictMode(11819): 	at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
D/StrictMode(11819): 	at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
D/StrictMode(11819): 	at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2906)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3283)
D/StrictMode(11819): 	at android.view.View.layout(View.java:13754)
D/StrictMode(11819): 	at android.view.ViewGroup.layout(ViewGroup.java:4364)
D/StrictMode(11819): 	at android.support.v4.view.ViewPager.onLayout(ViewPager.java:1695)
D/StrictMode(11819): 	at android.view.View.layout(View.java:13754)
D/StrictMode(11819): 	at android.view.ViewGroup.layout(ViewGroup.java:4364)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView$LayoutManager.layoutDecorated(RecyclerView.java:7650)
D/StrictMode(11819): 	at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1448)
D/StrictMode(11819): 	at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1353)
D/StrictMode(11819): 	at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:574)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3028)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2906)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1472)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView.access$400(RecyclerView.java:147)
D/StrictMode(11819): 	at android.support.v7.widget.RecyclerView$1.run(RecyclerView.java:294)
D/StrictMode(11819): 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
D/StrictMode(11819): 	at android.view.Choreographer.doCallbacks(Choreographer.java:555)
D/StrictMode(11819): 	at android.view.Choreographer.doFrame(Choreographer.java:524)
D/StrictMode(11819): 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
D/StrictMode(11819): 	at android.os.Handler.handleCallback(Handler.java:615)
D/StrictMode(11819): 	at android.os.Handler.dispatchMessage(Handler.java:92)
D/StrictMode(11819): 	at android.os.Looper.loop(Looper.java:137)
D/StrictMode(11819): 	at android.app.ActivityThread.main(ActivityThread.java:4745)
D/StrictMode(11819): 	at java.lang.reflect.Method.invokeNative(Native Method)
D/StrictMode(11819): 	at java.lang.reflect.Method.invoke
UUID hits the disk? Curious. I'll take a look tomorrow.
tracking-fennec: --- → ?
Flags: needinfo?(michael.l.comella)
It looks like we are reading from /dev/urandom [1]. Since this is a special file and urandom is non-blocking, afaik we're not touching the disk or have a similar perf overhead so it should be fine to surround this read with a StrictMode override.

Since StrictMode is strictly (ha!) for developer builds, this won't need an uplift.

[1]: http://searchfox.org/mozilla-central/rev/f6dc0e40b51a37c34e1683865395e72e7fca592c/mobile/android/services/src/main/java/org/mozilla/gecko/util/PRNGFixes.java#267
Assignee: nobody → michael.l.comella
Flags: needinfo?(michael.l.comella)
That being said, I'm unable to reproduce this. Grisha, do you know how you can reproduce this warning? I wonder if, on occasion, /dev/urandom is actually pulling entropy from the disk. That being said, it's non-blocking so I'm not sure we'd see any performance hits.
Flags: needinfo?(gkruglov)
Priority: -- → P3
I'm only working on P1 AS issues atm so unassigning.
Assignee: michael.l.comella → nobody
I most likely saw this in emulator (I imagine /dev/urandom might behave quite differently than on an actual device) logs while working on something unrelated. I recall it was showing up pretty consistently. Sorry, don't have more details than that.
Flags: needinfo?(gkruglov)
fwiw, I think I was trying to repro on device.
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.