Commit 1dc0dde
AnnotationManagerImpl cleanup images on delete (#11010)
https://mapbox.atlassian.net/browse/MAPSAND-2595
## Changes
### `AnnotationManagerImpl` ref-counted style image tracking
Added a `StyleImages` inner class that tracks a reference count per
style image ID. Each annotation that holds an `_iconImage` starting with
`ICON_DEFAULT_NAME_PREFIX` increments the counter on creation and
decrements it on deletion. The style image is removed from the map only
when the count reaches zero.
The manager-level `iconImageBitmap` setter calls `addStyleImage()` →
`styleImages.put(imageId)`, contributing its own ref-count entry. That
entry is released by `deleteAll()` / manager teardown, but not by
deleting individual annotations that don't carry an explicit
`iconImage`.
### `PointAnnotation._iconImage` internal property + deprecation
The existing public `iconImage` property now delegates to `_iconImage`
and its getter is marked `@Deprecated`
## Tests for style image reference count
| Test | Scenario |
|------|----------|
| `delete annotation with unique bitmap removes style image` | Single
annotation deleted → image removed |
| `deleteAll removes all unique style images` | Two unique bitmaps,
deleteAll → both removed |
| `deleting first of two shared-bitmap annotations preserves style
image` | Same bitmap, delete one → image stays |
| `deleting both shared-bitmap annotations removes style image` | Same
bitmap, delete both → image removed |
| `deleting source annotation preserves style image when cached-id
annotation is alive` | A+B share id string, delete A → image stays;
delete B → image removed |
| `deleting individual annotation does not remove manager-level style
image` | `manager.iconImageBitmap` set, delete annotation without
explicit iconImage → image stays |
| `deleteAll removes manager-level style image` |
`manager.iconImageBitmap` set, deleteAll → image removed |
| `creating annotation with previously deleted image re-adds style
image` | Delete A (image removed), create B with same bitmap → image
re-uploaded |
| `creating string-id annotation after source annotation deleted does
not re-add style image` | Delete A (image removed), create B with cached
ID string only → image absent from style, B not shown |
## Caveats
1. If a user caches the image ID string from one annotation, deletes
that annotation (which removes the image from the style), and then
creates a new annotation with the cached ID via `withIconImage(String)`.
The new annotation will not be rendered because no bitmap is available
to re-upload the image.
2. Annotations sharing the same bitmap (same `hashCode`) share the same
image ID and ref-count entry. Each creation increments and each deletion
decrements the shared counter. Ticket
https://mapbox.atlassian.net/browse/MAPSAND-2593
cc @mapbox/maps-android
cc @mapbox/sdk-platform
GitOrigin-RevId: 12b93934af2b15dba6849d02388e3be4b48af5b11 parent 07695d5 commit 1dc0dde
File tree
8 files changed
+537
-57
lines changed- app/src/main/java/com/mapbox/maps/testapp/examples/markersandcallouts/viewannotation
- plugin-annotation
- api/Release
- src
- main/java/com/mapbox/maps/plugin/annotation
- generated
- test/java/com/mapbox/maps/plugin/annotation
- generated
8 files changed
+537
-57
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | | - | |
| 351 | + | |
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
| |||
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | | - | |
| 444 | + | |
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| |||
Lines changed: 51 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
| |||
546 | 547 | | |
547 | 548 | | |
548 | 549 | | |
| 550 | + | |
549 | 551 | | |
550 | 552 | | |
551 | 553 | | |
| |||
557 | 559 | | |
558 | 560 | | |
559 | 561 | | |
| 562 | + | |
560 | 563 | | |
561 | 564 | | |
562 | 565 | | |
| |||
568 | 571 | | |
569 | 572 | | |
570 | 573 | | |
| 574 | + | |
571 | 575 | | |
572 | 576 | | |
| 577 | + | |
573 | 578 | | |
574 | 579 | | |
575 | 580 | | |
| |||
587 | 592 | | |
588 | 593 | | |
589 | 594 | | |
| 595 | + | |
590 | 596 | | |
591 | 597 | | |
| 598 | + | |
592 | 599 | | |
593 | 600 | | |
594 | 601 | | |
| |||
612 | 619 | | |
613 | 620 | | |
614 | 621 | | |
| 622 | + | |
615 | 623 | | |
616 | 624 | | |
617 | 625 | | |
| |||
645 | 653 | | |
646 | 654 | | |
647 | 655 | | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
| 656 | + | |
660 | 657 | | |
661 | 658 | | |
662 | 659 | | |
663 | 660 | | |
664 | 661 | | |
665 | 662 | | |
666 | 663 | | |
667 | | - | |
| 664 | + | |
668 | 665 | | |
669 | 666 | | |
670 | 667 | | |
| |||
774 | 771 | | |
775 | 772 | | |
776 | 773 | | |
777 | | - | |
| 774 | + | |
778 | 775 | | |
779 | 776 | | |
780 | 777 | | |
| |||
1001 | 998 | | |
1002 | 999 | | |
1003 | 1000 | | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1004 | 1041 | | |
1005 | 1042 | | |
1006 | 1043 | | |
| |||
Lines changed: 29 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 35 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments