Repository navigation
[NET11][Android] [ShellHandler] Fix ScrollView crash when reparenting native content - #39759
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39759Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39759" |
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.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit 4a5277f.
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.
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.
This comment has been minimized.
This comment has been minimized.
Tests Failure Analysis
🧪 CI Analysis — click to expand📊 maui-prNo failures found. 🧪 maui-pr-devicetestsNo failures found. 🧪 maui-pr-uitests
🧭 Follow-up — actions and refreshNext action: Restore the missing latest-attempt logs and investigate the Mac drag/drop timeout before attributing the remaining failures.
|
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit 31b067c.
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: 31b067c7. Without-fix baseline: 13832fce. |
44b41d2
into
dotnet:candidate/11.0.1xx-sr2
… native content (#39759) <!-- 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! ### Issue Detail On Android, a ScrollView can crash when its handler attaches content to an internal container: Java.Lang.IllegalStateException: The specified child already has a parent. ### Root cause The handler adds native content to an inset container without first detaching it from its existing parent. Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent. ### Description of Change Call nativeContent.RemoveFromParent() before adding the content in both scenarios: - Creating a new inset container. - Replacing content in an existing inset container. This safely reparents the existing content without changing the measurement or scrolling logic. ### Issues Fixed Fixes #39758 ### Screenshot | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="850" height="350" src="https://github.com/user-attachments/assets/ce58d0f3-a797-4eaa-af8e-0404cfdb8cda"> | <img width="350" height="350" src="https://github.com/user-attachments/assets/8786d5fe-3b01-4020-9cb9-2aa461919d92"> | Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… native content (#39759) <!-- 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! ### Issue Detail On Android, a ScrollView can crash when its handler attaches content to an internal container: Java.Lang.IllegalStateException: The specified child already has a parent. ### Root cause The handler adds native content to an inset container without first detaching it from its existing parent. Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent. ### Description of Change Call nativeContent.RemoveFromParent() before adding the content in both scenarios: - Creating a new inset container. - Replacing content in an existing inset container. This safely reparents the existing content without changing the measurement or scrolling logic. ### Issues Fixed Fixes #39758 ### Screenshot | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="850" height="350" src="https://github.com/user-attachments/assets/ce58d0f3-a797-4eaa-af8e-0404cfdb8cda"> | <img width="350" height="350" src="https://github.com/user-attachments/assets/8786d5fe-3b01-4020-9cb9-2aa461919d92"> | Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… native content (#39759) <!-- 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! ### Issue Detail On Android, a ScrollView can crash when its handler attaches content to an internal container: Java.Lang.IllegalStateException: The specified child already has a parent. ### Root cause The handler adds native content to an inset container without first detaching it from its existing parent. Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent. ### Description of Change Call nativeContent.RemoveFromParent() before adding the content in both scenarios: - Creating a new inset container. - Replacing content in an existing inset container. This safely reparents the existing content without changing the measurement or scrolling logic. ### Issues Fixed Fixes #39758 ### Screenshot | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="850" height="350" src="https://github.com/user-attachments/assets/ce58d0f3-a797-4eaa-af8e-0404cfdb8cda"> | <img width="350" height="350" src="https://github.com/user-attachments/assets/8786d5fe-3b01-4020-9cb9-2aa461919d92"> | Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… native content (#39759) <!-- 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! ### Issue Detail On Android, a ScrollView can crash when its handler attaches content to an internal container: Java.Lang.IllegalStateException: The specified child already has a parent. ### Root cause The handler adds native content to an inset container without first detaching it from its existing parent. Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent. ### Description of Change Call nativeContent.RemoveFromParent() before adding the content in both scenarios: - Creating a new inset container. - Replacing content in an existing inset container. This safely reparents the existing content without changing the measurement or scrolling logic. ### Issues Fixed Fixes #39758 ### Screenshot | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="850" height="350" src="https://github.com/user-attachments/assets/ce58d0f3-a797-4eaa-af8e-0404cfdb8cda"> | <img width="350" height="350" src="https://github.com/user-attachments/assets/8786d5fe-3b01-4020-9cb9-2aa461919d92"> | Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… native content (#39759) <!-- 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! ### Issue Detail On Android, a ScrollView can crash when its handler attaches content to an internal container: Java.Lang.IllegalStateException: The specified child already has a parent. ### Root cause The handler adds native content to an inset container without first detaching it from its existing parent. Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent. ### Description of Change Call nativeContent.RemoveFromParent() before adding the content in both scenarios: - Creating a new inset container. - Replacing content in an existing inset container. This safely reparents the existing content without changing the measurement or scrolling logic. ### Issues Fixed Fixes #39758 ### Screenshot | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="850" height="350" src="https://github.com/user-attachments/assets/ce58d0f3-a797-4eaa-af8e-0404cfdb8cda"> | <img width="350" height="350" src="https://github.com/user-attachments/assets/8786d5fe-3b01-4020-9cb9-2aa461919d92"> | Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… native content (#39759) <!-- 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! ### Issue Detail On Android, a ScrollView can crash when its handler attaches content to an internal container: Java.Lang.IllegalStateException: The specified child already has a parent. ### Root cause The handler adds native content to an inset container without first detaching it from its existing parent. Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent. ### Description of Change Call nativeContent.RemoveFromParent() before adding the content in both scenarios: - Creating a new inset container. - Replacing content in an existing inset container. This safely reparents the existing content without changing the measurement or scrolling logic. ### Issues Fixed Fixes #39758 ### Screenshot | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="850" height="350" src="https://github.com/user-attachments/assets/ce58d0f3-a797-4eaa-af8e-0404cfdb8cda"> | <img width="350" height="350" src="https://github.com/user-attachments/assets/8786d5fe-3b01-4020-9cb9-2aa461919d92"> | Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… native content (#39759) <!-- 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! ### Issue Detail On Android, a ScrollView can crash when its handler attaches content to an internal container: Java.Lang.IllegalStateException: The specified child already has a parent. ### Root cause The handler adds native content to an inset container without first detaching it from its existing parent. Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent. ### Description of Change Call nativeContent.RemoveFromParent() before adding the content in both scenarios: - Creating a new inset container. - Replacing content in an existing inset container. This safely reparents the existing content without changing the measurement or scrolling logic. ### Issues Fixed Fixes #39758 ### Screenshot | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="850" height="350" src="https://github.com/user-attachments/assets/ce58d0f3-a797-4eaa-af8e-0404cfdb8cda"> | <img width="350" height="350" src="https://github.com/user-attachments/assets/8786d5fe-3b01-4020-9cb9-2aa461919d92"> | Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… native content (#39759) <!-- 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! ### Issue Detail On Android, a ScrollView can crash when its handler attaches content to an internal container: Java.Lang.IllegalStateException: The specified child already has a parent. ### Root cause The handler adds native content to an inset container without first detaching it from its existing parent. Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent. ### Description of Change Call nativeContent.RemoveFromParent() before adding the content in both scenarios: - Creating a new inset container. - Replacing content in an existing inset container. This safely reparents the existing content without changing the measurement or scrolling logic. ### Issues Fixed Fixes #39758 ### Screenshot | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="850" height="350" src="https://github.com/user-attachments/assets/ce58d0f3-a797-4eaa-af8e-0404cfdb8cda"> | <img width="350" height="350" src="https://github.com/user-attachments/assets/8786d5fe-3b01-4020-9cb9-2aa461919d92"> | Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… native content (#39759) <!-- 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! ### Issue Detail On Android, a ScrollView can crash when its handler attaches content to an internal container: Java.Lang.IllegalStateException: The specified child already has a parent. ### Root cause The handler adds native content to an inset container without first detaching it from its existing parent. Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent. ### Description of Change Call nativeContent.RemoveFromParent() before adding the content in both scenarios: - Creating a new inset container. - Replacing content in an existing inset container. This safely reparents the existing content without changing the measurement or scrolling logic. ### Issues Fixed Fixes #39758 ### Screenshot | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="850" height="350" src="https://github.com/user-attachments/assets/ce58d0f3-a797-4eaa-af8e-0404cfdb8cda"> | <img width="350" height="350" src="https://github.com/user-attachments/assets/8786d5fe-3b01-4020-9cb9-2aa461919d92"> | Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
… native content (#39759) <!-- 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! ### Issue Detail On Android, a ScrollView can crash when its handler attaches content to an internal container: Java.Lang.IllegalStateException: The specified child already has a parent. ### Root cause The handler adds native content to an inset container without first detaching it from its existing parent. Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent. ### Description of Change Call nativeContent.RemoveFromParent() before adding the content in both scenarios: - Creating a new inset container. - Replacing content in an existing inset container. This safely reparents the existing content without changing the measurement or scrolling logic. ### Issues Fixed Fixes #39758 ### Screenshot | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="850" height="350" src="https://github.com/user-attachments/assets/ce58d0f3-a797-4eaa-af8e-0404cfdb8cda"> | <img width="350" height="350" src="https://github.com/user-attachments/assets/8786d5fe-3b01-4020-9cb9-2aa461919d92"> | 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!
Issue Detail
On Android, a ScrollView can crash when its handler attaches content to an internal container:
Java.Lang.IllegalStateException: The specified child already has a parent.
Root cause
The handler adds native content to an inset container without first detaching it from its existing parent.
Removing the ScrollView's immediate children does not detach content nested inside those containers. Android throws an exception when adding a view that already has a parent, as each native view can have only one parent.
Description of Change
Call nativeContent.RemoveFromParent() before adding the content in both scenarios:
This safely reparents the existing content without changing the measurement or scrolling logic.
Issues Fixed
Fixes #39758
Screenshot