Repository navigation
[Android] Shell: Don't throw when resuming the fragment of a removed ShellSection - #40052
Conversation
…ShellSection ShellSectionWrapperFragment.OnResume guarded against a disconnected handler with _handler.VirtualView is null, but the typed ElementHandler<,>.VirtualView getter throws once the handler is disconnected. FragmentManager keeps the fragment after its section is removed and can resume it later, e.g. when the section was removed while the app was in the background, so the app crashed with "VirtualView cannot be null here". Check the untyped VirtualView instead. Fixes dotnet#40051
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40052Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40052" |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Hey there @@Dreamescaper! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
Hey there @Dreamescaper! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit 25d3ba3.
PR Test Gate
🧪 Gate analysis — click to expand✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence. 📱 Device tests
Execution log excerptsWithout fix With fix PR head: 25d3ba39. Without-fix baseline: 9fb91b46. |
c476908
into
dotnet:candidate/11.0.1xx-sr2
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
…ShellSection (#40052) <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change On Android with the handler-based Shell, an app crashes with `InvalidOperationException: VirtualView cannot be null here` in `ShellSectionWrapperFragment.OnResume()` when it resumes after a ShellItem was replaced while it was in the background. When a section is removed, `ShellSectionHandlerAdapter.Dispose()` disconnects its handler. Since #37048 it leaves the wrapper fragment to `FragmentManager`, which can still resume it. `OnResume()` already returns early for a disconnected handler, but it checks `_handler.VirtualView is null`. That reads the typed `ElementHandler<ShellSection, AView>.VirtualView`, whose getter throws once disconnected, so the guard itself throws. The fix checks the untyped `((IElementHandler)_handler).VirtualView`, the same way `ShellSectionHandler.iOS.cs` does. Not changed here: several other `VirtualView is null` checks in `ShellSectionHandler.Android.cs` (for example in `IsCurrentlyActiveSection()` and `SetupViewPagerAdapter()`) have the same problem. They aren't reached on this path, so I left them out to keep this PR small. ### Tests Added `ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow`. It creates a section renderer, disposes it the same way `ShellItemHandler.UpdateSections` does for a removed section, and resumes its wrapper fragment. Ran `ShellHandlerTests_Shell` locally on an Android emulator (API 36, x86_64): - With the fix: 80/80 pass. - Without the fix: the new test fails with `System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume()`; the other 79 pass. ### Issues Fixed Fixes #40051 Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
On Android with the handler-based Shell, an app crashes with
InvalidOperationException: VirtualView cannot be null hereinShellSectionWrapperFragment.OnResume()when it resumes after a ShellItem was replaced while it was in the background.When a section is removed,
ShellSectionHandlerAdapter.Dispose()disconnects its handler. Since #37048 it leaves the wrapper fragment toFragmentManager, which can still resume it.OnResume()already returns early for a disconnected handler, but it checks_handler.VirtualView is null. That reads the typedElementHandler<ShellSection, AView>.VirtualView, whose getter throws once disconnected, so the guard itself throws.The fix checks the untyped
((IElementHandler)_handler).VirtualView, the same wayShellSectionHandler.iOS.csdoes.Not changed here: several other
VirtualView is nullchecks inShellSectionHandler.Android.cs(for example inIsCurrentlyActiveSection()andSetupViewPagerAdapter()) have the same problem. They aren't reached on this path, so I left them out to keep this PR small.Tests
Added
ShellHandlerTests_Shell.ResumingFragmentOfRemovedShellSectionDoesNotThrow. It creates a section renderer, disposes it the same wayShellItemHandler.UpdateSectionsdoes for a removed section, and resumes its wrapper fragment.Ran
ShellHandlerTests_Shelllocally on an Android emulator (API 36, x86_64):System.InvalidOperationException: VirtualView cannot be null here at ShellSectionWrapperFragment.OnResume(); the other 79 pass.Issues Fixed
Fixes #40051