Open BioTurboNick opened 11 months ago
I don't know if these are truly separate, but I'm seeing similar context violations in ShellFragmentContainer.OnCreateView()
, ContentViewGroup.OnMeasure()
, RunnableImplementor.Run()
[StrictMode] StrictMode policy violation: android.os.strictmode.IncorrectContextUseViolation: WindowManager should be accessed from Activity or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle), which are adjusted to the configuration and visual bounds of an area on screen.
[StrictMode] at android.os.StrictMode.onIncorrectContextUsed(StrictMode.java:2260)
[StrictMode] at android.app.ContextImpl.getSystemService(ContextImpl.java:2196)
[StrictMode] at android.content.ContextWrapper.getSystemService(ContextWrapper.java:917)
[StrictMode] at crc640ec207abc449b2ca.ShellFragmentContainer.n_onCreateView(Native Method)
[StrictMode] at crc640ec207abc449b2ca.ShellFragmentContainer.onCreateView(ShellFragmentContainer.java:41)
[StrictMode] at androidx.fragment.app.Fragment.performCreateView(Fragment.java:3114)
[StrictMode] at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:557)
[StrictMode] at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
[StrictMode] at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
[StrictMode] at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1839)
[StrictMode] at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1751)
[StrictMode] at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:317)
[StrictMode] at androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder(FragmentStateAdapter.java:341)
[StrictMode] at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:276)
[StrictMode] at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:67)
[StrictMode] at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:8291)
[StrictMode] at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:924)
[StrictMode] at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
[StrictMode] at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:9344)
[StrictMode] at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:9302)
[StrictMode] at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:9289)
[StrictMode] at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1676)
[StrictMode] at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1622)
[StrictMode] at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:687)
[StrictMode] at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4604)
[StrictMode] at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4307)
[StrictMode] at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4873)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:527)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at com.google.android.material.appbar.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:149)
[StrictMode] at com.google.android.material.appbar.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:43)
[StrictMode] at com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:2376)
[StrictMode] at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:953)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
[StrictMode] at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
[StrictMode] at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1273)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
[StrictMode] at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1818)
[StrictMode] at android.widget.LinearLayout.onLayout(LinearLayout.java:1584)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
[StrictMode] at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
[StrictMode] at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at com.android.internal.policy.DecorView.onLayout(DecorView.java:1431)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:4917)
[StrictMode] at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4240)
[StrictMode] at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3116)
[StrictMode] at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10885)
[StrictMode] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1301)
[StrictMode] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309)
[StrictMode] at android.view.Choreographer.doCallbacks(Choreographer.java:923)
[StrictMode] at android.view.Choreographer.doFrame(Choreographer.java:852)
[StrictMode] at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283)
[StrictMode] at android.os.Handler.handleCallback(Handler.java:942)
[StrictMode] at android.os.Handler.dispatchMessage(Handler.java:99)
[StrictMode] at android.os.Looper.loopOnce(Looper.java:226)
[StrictMode] at android.os.Looper.loop(Looper.java:313)
[StrictMode] at android.app.ActivityThread.main(ActivityThread.java:8762)
[StrictMode] at java.lang.reflect.Method.invoke(Native Method)
[StrictMode] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
[StrictMode] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
[StrictMode] Caused by: java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:crc64388215b9f0c408ca.MainApplication@485b95c
[StrictMode] at android.app.ContextImpl.getSystemService(ContextImpl.java:2195)
[StrictMode] ... 96 more
[StrictMode] StrictMode policy violation: android.os.strictmode.IncorrectContextUseViolation: WindowManager should be accessed from Activity or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle), which are adjusted to the configuration and visual bounds of an area on screen.
[StrictMode] at android.os.StrictMode.onIncorrectContextUsed(StrictMode.java:2260)
[StrictMode] at android.app.ContextImpl.getSystemService(ContextImpl.java:2196)
[StrictMode] at android.content.ContextWrapper.getSystemService(ContextWrapper.java:917)
[StrictMode] at crc6452ffdc5b34af3a0f.ContentViewGroup.n_onMeasure(Native Method)
[StrictMode] at crc6452ffdc5b34af3a0f.ContentViewGroup.onMeasure(ContentViewGroup.java:59)
[StrictMode] at android.view.View.measure(View.java:27731)
[StrictMode] at crc640ec207abc449b2ca.ShellPageContainer.n_onMeasure(Native Method)
[StrictMode] at crc640ec207abc449b2ca.ShellPageContainer.onMeasure(ShellPageContainer.java:66)
[StrictMode] at android.view.View.measure(View.java:27731)
[StrictMode] at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7352)
[StrictMode] at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
[StrictMode] at android.view.View.measure(View.java:27731)
[StrictMode] at androidx.recyclerview.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:10124)
[StrictMode] at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1688)
[StrictMode] at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1622)
[StrictMode] at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:687)
[StrictMode] at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4604)
[StrictMode] at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:4307)
[StrictMode] at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4873)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at androidx.viewpager2.widget.ViewPager2.onLayout(ViewPager2.java:527)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at com.google.android.material.appbar.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:149)
[StrictMode] at com.google.android.material.appbar.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:43)
[StrictMode] at com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:2376)
[StrictMode] at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:953)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
[StrictMode] at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
[StrictMode] at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1273)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
[StrictMode] at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1818)
[StrictMode] at android.widget.LinearLayout.onLayout(LinearLayout.java:1584)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1829)
[StrictMode] at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1673)
[StrictMode] at android.widget.LinearLayout.onLayout(LinearLayout.java:1582)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332)
[StrictMode] at android.widget.FrameLayout.onLayout(FrameLayout.java:270)
[StrictMode] at com.android.internal.policy.DecorView.onLayout(DecorView.java:1431)
[StrictMode] at android.view.View.layout(View.java:24969)
[StrictMode] at android.view.ViewGroup.layout(ViewGroup.java:6784)
[StrictMode] at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:4917)
[StrictMode] at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4240)
[StrictMode] at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:3116)
[StrictMode] at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10885)
[StrictMode] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1301)
[StrictMode] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309)
[StrictMode] at android.view.Choreographer.doCallbacks(Choreographer.java:923)
[StrictMode] at android.view.Choreographer.doFrame(Choreographer.java:852)
[StrictMode] at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283)
[StrictMode] at android.os.Handler.handleCallback(Handler.java:942)
[StrictMode] at android.os.Handler.dispatchMessage(Handler.java:99)
[StrictMode] at android.os.Looper.loopOnce(Looper.java:226)
[StrictMode] at android.os.Looper.loop(Looper.java:313)
[StrictMode] at android.app.ActivityThread.main(ActivityThread.java:8762)
[StrictMode] at java.lang.reflect.Method.invoke(Native Method)
[StrictMode] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
[StrictMode] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
[StrictMode] Caused by: java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:crc64388215b9f0c408ca.MainApplication@485b95c
[StrictMode] at android.app.ContextImpl.getSystemService(ContextImpl.java:2195)
[StrictMode] ... 88 more
[StrictMode] StrictMode policy violation: android.os.strictmode.IncorrectContextUseViolation: WindowManager should be accessed from Activity or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle), which are adjusted to the configuration and visual bounds of an area on screen.
[StrictMode] at android.os.StrictMode.onIncorrectContextUsed(StrictMode.java:2260)
[StrictMode] at android.app.ContextImpl.getSystemService(ContextImpl.java:2196)
[StrictMode] at android.content.ContextWrapper.getSystemService(ContextWrapper.java:917)
[StrictMode] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[StrictMode] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31)
[StrictMode] at android.os.Handler.handleCallback(Handler.java:942)
[StrictMode] at android.os.Handler.dispatchMessage(Handler.java:99)
[StrictMode] at android.os.Looper.loopOnce(Looper.java:226)
[StrictMode] at android.os.Looper.loop(Looper.java:313)
[StrictMode] at android.app.ActivityThread.main(ActivityThread.java:8762)
[StrictMode] at java.lang.reflect.Method.invoke(Native Method)
[StrictMode] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
[StrictMode] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
[StrictMode] Caused by: java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:crc64388215b9f0c408ca.MainApplication@485b95c
[StrictMode] at android.app.ContextImpl.getSystemService(ContextImpl.java:2195)
[StrictMode] ... 11 more
[ContextImpl] Tried to access visual service WindowManager from a non-visual Context:crc64388215b9f0c408ca.MainApplication@485b95c WindowManager should be accessed from Activity or other visual Context. Use an Activity or a Context created with Context#createWindowContext(int, Bundle), which are adjusted to the configuration and visual bounds of an area on screen.
[ContextImpl] java.lang.IllegalAccessException: Tried to access visual service WindowManager from a non-visual Context:crc64388215b9f0c408ca.MainApplication@485b95c
[ContextImpl] at android.app.ContextImpl.getSystemService(ContextImpl.java:2195)
[ContextImpl] at android.content.ContextWrapper.getSystemService(ContextWrapper.java:917)
[ContextImpl] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[ContextImpl] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31)
[ContextImpl] at android.os.Handler.handleCallback(Handler.java:942)
[ContextImpl] at android.os.Handler.dispatchMessage(Handler.java:99)
[ContextImpl] at android.os.Looper.loopOnce(Looper.java:226)
[ContextImpl] at android.os.Looper.loop(Looper.java:313)
[ContextImpl] at android.app.ActivityThread.main(ActivityThread.java:8762)
[ContextImpl] at java.lang.reflect.Method.invoke(Native Method)
[ContextImpl] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
[ContextImpl] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Hi @BioTurboNick. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
I've added a repro to the OP. It's just the stock MAUI default project with StrictMode turned on. The error will show in the debug logs.
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
Description
When investigating ANRs in my app, I turned on StrictMode violation logging. I found that
ShellSectionRenderer.OnCreateView()
is causing anIllegalAccessException
attempting to access theWindowManager
, which turned into anIncorrectContextUseViolation
.Steps to Reproduce
No response
Link to public reproduction project repository
MauiApp3.csproj.zip
Version with bug
8.0.3
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 13
Did you find any workaround?
No response
Relevant log output