Skip to content

Conversation

@mahmoudadel54
Copy link
Contributor

Description

This PR includes:

  • prevent OOM by enforcing projection-aware resolutions in new.json file in mapOptions.view
  • Add strict check: only use configured resolutions if view.projection in new.json file matches target SRS in createView
  • Eliminates infinite tile loading and out-of-memory crashes when switching to different CRS
  • fix print file by passing the projection prop with resolutions to gurantee the above check

** the new edits includes -> a projection should be added to resolutions/scales in mapOptions.view in new.json file to be read properly. **

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

What is the current behavior?
#11779

What is the new behavior?

The OOM behavior not happen now if a resolutions and projection provided in new.json file and user switch to different projection rather than the resolutions one.

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

This new.json for test

{
  "version": 2,
  "map": {
    "projection": "EPSG:900913",
    "units": "m",
    "center": { "x": 1250000.0, "y": 5370000.0, "crs": "EPSG:900913" },
    "zoom": 5,
    "mapOptions": {
      "view": {
        "resolutions": [
          84666.66666666688,
          42333.33333333344,
          21166.66666666672,
          10583.33333333336,
          5291.66666666668,
          2645.83333333334,
          1322.91666666667,
          661.458333333335000,
          529.166666666668000,
          396.875000000001000,
          264.583333333334000,
          132.291666666667000,
          66.145833333333500,
          39.687500000000100,
          26.458333333333400,
          13.229166666666700,
          6.614583333333350,
          3.968750000000010,
          2.645833333333340,
          1.322916666666670,
          0.661458333333335
        ],
        "projection": "EPSG:3857"
      }
    },
    "maxExtent": [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
    "layers": [
      {
        "format": "image/jpeg",
        "group": "background",
        "name": "osm:osm_simple_light",
        "opacity": 1,
        "title": "OSM Simple Light",
        "thumbURL": "product/assets/img/osm-simple-light.jpg",
        "type": "wms",
        "url": [
          "https://maps1.geosolutionsgroup.com/geoserver/wms",
          "https://maps2.geosolutionsgroup.com/geoserver/wms",
          "https://maps3.geosolutionsgroup.com/geoserver/wms",
          "https://maps4.geosolutionsgroup.com/geoserver/wms",
          "https://maps5.geosolutionsgroup.com/geoserver/wms",
          "https://maps6.geosolutionsgroup.com/geoserver/wms"
        ],
        "tileSize": 512,
        "visibility": false,
        "singleTile": false,
        "credits": {
          "title": "OSM Simple Light | Rendering <a href=\"https://www.geo-solutions.it/\">GeoSolutions</a> | Data © <a href=\"http://www.openstreetmap.org/\">OpenStreetMap</a> contributors, <a href=\"http://www.openstreetmap.org/copyright\">ODbL</a>"
        }
      },
      {
        "format": "image/jpeg",
        "group": "background",
        "name": "osm:osm_simple_dark",
        "opacity": 1,
        "title": "OSM Simple Dark",
        "thumbURL": "product/assets/img/osm-simple-dark.jpg",
        "type": "wms",
        "url": [
          "https://maps6.geosolutionsgroup.com/geoserver/wms",
          "https://maps3.geosolutionsgroup.com/geoserver/wms",
          "https://maps1.geosolutionsgroup.com/geoserver/wms",
          "https://maps4.geosolutionsgroup.com/geoserver/wms",
          "https://maps2.geosolutionsgroup.com/geoserver/wms",
          "https://maps5.geosolutionsgroup.com/geoserver/wms"
        ],
        "tileSize": 512,
        "visibility": false,
        "singleTile": false,
        "credits": {
          "title": "OSM Simple Dark | Rendering <a href=\"https://www.geo-solutions.it/\">GeoSolutions</a> | Data © <a href=\"http://www.openstreetmap.org/\">OpenStreetMap</a> contributors, <a href=\"http://www.openstreetmap.org/copyright\">ODbL</a>"
        }
      },
      {
        "format": "image/jpeg",
        "group": "background",
        "name": "osm:osm",
        "opacity": 1,
        "title": "OSM Bright",
        "thumbURL": "product/assets/img/osm-bright.jpg",
        "type": "wms",
        "url": [
          "https://maps1.geosolutionsgroup.com/geoserver/wms",
          "https://maps2.geosolutionsgroup.com/geoserver/wms",
          "https://maps3.geosolutionsgroup.com/geoserver/wms",
          "https://maps4.geosolutionsgroup.com/geoserver/wms",
          "https://maps5.geosolutionsgroup.com/geoserver/wms",
          "https://maps6.geosolutionsgroup.com/geoserver/wms"
        ],
        "tileSize": 512,
        "visibility": true,
        "singleTile": false,
        "credits": {
          "title": "OSM Bright | Rendering <a href=\"https://www.geo-solutions.it/\">GeoSolutions</a> | Data © <a href=\"http://www.openstreetmap.org/\">OpenStreetMap</a> contributors, <a href=\"http://www.openstreetmap.org/copyright\">ODbL</a>"
        }
      },
      {
        "format": "image/jpeg",
        "group": "background",
        "name": "ne:ne-political",
        "opacity": 1,
        "title": "NE Political",
        "thumbURL": "product/assets/img/ne-political.jpg",
        "type": "wms",
        "url": [
          "https://maps1.geosolutionsgroup.com/geoserver/wms",
          "https://maps2.geosolutionsgroup.com/geoserver/wms",
          "https://maps3.geosolutionsgroup.com/geoserver/wms",
          "https://maps4.geosolutionsgroup.com/geoserver/wms",
          "https://maps5.geosolutionsgroup.com/geoserver/wms",
          "https://maps6.geosolutionsgroup.com/geoserver/wms"
        ],
        "tileSize": 512,
        "visibility": false,
        "singleTile": false,
        "credits": {
          "title": "<p></p>\n"
        }
      },
      {
        "format": "image/jpeg",
        "group": "background",
        "name": "s2cloudless:s2cloudless",
        "opacity": 1,
        "title": "Sentinel 2 Cloudless",
        "type": "wms",
        "url": [
          "https://maps1.geosolutionsgroup.com/geoserver/wms",
          "https://maps2.geosolutionsgroup.com/geoserver/wms",
          "https://maps3.geosolutionsgroup.com/geoserver/wms",
          "https://maps4.geosolutionsgroup.com/geoserver/wms",
          "https://maps5.geosolutionsgroup.com/geoserver/wms",
          "https://maps6.geosolutionsgroup.com/geoserver/wms"
        ],
        "tileSize": 512,
        "source": "s2cloudless",
        "singleTile": false,
        "visibility": false
      },
      {
        "type": "osm",
        "title": "Open Street Map",
        "name": "mapnik",
        "source": "osm",
        "group": "background",
        "visibility": false
      },
      {
        "source": "ol",
        "group": "background",
        "title": "Empty Background",
        "fixed": true,
        "type": "empty",
        "visibility": false
      }
    ]
  }
}

I think guides should be added for this edit

Copy link
Member

@tdipisa tdipisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mahmoudadel54 what about old maps having the old configuration? Probably we should at least automatically update the map state at loading time so that the new logic is applied and when the map is saved the new configuration is also persisted. All in a transparent and automated way ensuring also a good backward compatibility. What do you think @MV88? Up to you to review.

@tdipisa tdipisa marked this pull request as ready for review December 11, 2025 14:49
@tdipisa tdipisa assigned MV88 and unassigned mahmoudadel54 Dec 11, 2025
Copy link
Contributor

@MV88 MV88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mahmoudadel54 not much to say, but one thing to be sure

@tdipisa
Copy link
Member

tdipisa commented Dec 12, 2025

@mahmoudadel54 not much to say, but one thing to be sure

What about #11788 (review) @MV88?

@mahmoudadel54 mahmoudadel54 requested a review from MV88 December 12, 2025 11:27
Copy link
Contributor

@MV88 MV88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…e if resolutions configured in new.json file with a different projection

Description:
- prevent OOM by enforcing projection-aware resolutions in new.json file in mapOptions.view
- Add strict check: only use configured resolutions if `view.projection` matches target SRS
- Eliminates infinite tile loading and out-of-memory crashes when switching to different CRS
- fix print file by passing the projection prop with resolutions to gurantee the above check
- add unit test
…e if resolutions configured in new.json file with a different projection

Description:
- edit unit test uses resolutions without projection
@MV88 MV88 merged commit 4e68715 into geosolutions-it:master Dec 12, 2025
5 checks passed
github-actions bot pushed a commit that referenced this pull request Dec 12, 2025
…f resolutions configured in new.json file with a different projection (#11788)

* #11779: FIX Setting the map projection crashes MapStore if resolutions configured in new.json file with a different projection
Description:
- prevent OOM by enforcing projection-aware resolutions in new.json file in mapOptions.view
- Add strict check: only use configured resolutions if `view.projection` matches target SRS
- Eliminates infinite tile loading and out-of-memory crashes when switching to different CRS
- fix print file by passing the projection prop with resolutions to gurantee the above check
- add unit test

* #11779: FIX Setting the map projection crashes MapStore if resolutions configured in new.json file with a different projection
Description:
- edit unit test uses resolutions without projection

* - resolve review comments by editing the order of viewOptions in openlayers/Map.js

(cherry picked from commit 4e68715)
@github-actions
Copy link
Contributor

@tdipisa
Copy link
Member

tdipisa commented Dec 12, 2025

@ElenaGallo waiting for you for before merging the backport

@tdipisa
Copy link
Member

tdipisa commented Dec 12, 2025

@mahmoudadel54 not much to say, but one thing to be sure

What about #11788 (review) @MV88?

@MV88 I saw you have merged, but can I have an answer to this please?

@ElenaGallo
Copy link
Contributor

Test passed, @tdipisa backport can be merged

@MV88
Copy link
Contributor

MV88 commented Dec 15, 2025

Test passed, @tdipisa backport can be merged

we have noticed that current implementation might require an additional effort in order to cover all cases, see here #11779 (comment)

i'll revert this

MV88 added a commit to MV88/MapStore2 that referenced this pull request Dec 15, 2025
… MapStore causing OOM if resolutions configured in new.json file with a different projection (geosolutions-it#11788)"

This reverts commit 4e68715.
offtherailz pushed a commit that referenced this pull request Dec 17, 2025
…ng OOM if resolutions configured in new.json file with a different projection (#11788)" (#11821)

This reverts commit 4e68715.
mahesh-wor pushed a commit to mahesh-wor/MapStore2 that referenced this pull request Dec 17, 2025
…e causing OOM if resolutions configured in new.json file with a different projection (geosolutions-it#11788)

* geosolutions-it#11779: FIX Setting the map projection crashes MapStore if resolutions configured in new.json file with a different projection
Description:
- prevent OOM by enforcing projection-aware resolutions in new.json file in mapOptions.view
- Add strict check: only use configured resolutions if `view.projection` matches target SRS
- Eliminates infinite tile loading and out-of-memory crashes when switching to different CRS
- fix print file by passing the projection prop with resolutions to gurantee the above check
- add unit test

* geosolutions-it#11779: FIX Setting the map projection crashes MapStore if resolutions configured in new.json file with a different projection
Description:
- edit unit test uses resolutions without projection

* - resolve review comments by editing the order of viewOptions in openlayers/Map.js
mahesh-wor pushed a commit to mahesh-wor/MapStore2 that referenced this pull request Dec 17, 2025
… MapStore causing OOM if resolutions configured in new.json file with a different projection (geosolutions-it#11788)" (geosolutions-it#11821)

This reverts commit 4e68715.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setting the map projection crashes MapStore if resolutions configured in new.json file with a different projection

4 participants