Skip to content

experimental: Canvas 3x rendering expansion to prevent white space during pan - #4753

Open
lmotta wants to merge 2 commits into
MerginMaps:masterfrom
lmotta:feature/expanded-canvas-3x
Open

lmotta wants to merge 2 commits into
MerginMaps:masterfrom
lmotta:feature/expanded-canvas-3x

Conversation

@lmotta

@lmotta lmotta commented Oct 17, 2026

Copy link
Copy Markdown

Description

This is an experimental PR to evaluate the impact and review workflow for expanding the map canvas rendering area (3x viewport).

Summary of Changes

  • Multiplied output size and extent by 3x in InputMapCanvasMap::refreshMap() to render a pre-buffered 3x3 grid.
  • Adjusted transformation scale and position offsets in InputMapCanvasMap::updateTransform().
  • Rescaled and translated the texture node in InputMapCanvasMap::updatePaintNode() to keep the physical viewport centered.

Purpose

Prevents blank/unrendered white spaces from appearing during pan and drag gestures on mobile devices.

@tomasMizera
tomasMizera self-requested a review October 19, 2026 15:14
@tomasMizera

Copy link
Copy Markdown
Collaborator

Hi @lmotta Luiz, thank you for the PR, we'll have a look at this. Can you attach screens/video how the app now works on your device?

@lmotta

lmotta commented Oct 20, 2026 •

Copy link
Copy Markdown
Author

Hi @tomasMizera,

merginmaps_3xmapcanvas_mute.mp4

In the video, on the left is the original Mergin Maps, and on the right is Mergin Maps with the 3x map canvas feature.

@tomasMizera tomasMizera left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I had a look at the code and I am bit worried to simply enroll this to everyone. The main problem is that the main thread now renders 9x the pixels compared to what we do now. This could produce a degraded user experience (slower rendering) on more complex projects.

Ideally, the map tiles/screens around the phone should render only after the main screen is rendered or be split into multiple threads at least.

QGIS map canvas API has this option called setPreviewJobsEnabled that seem to be the solution on QGIS desktop side of things. Let's have a look if we can port that to the app too.

@tomasMizera

Copy link
Copy Markdown
Collaborator

I built the branch locally and I can confirm that the feeling of working with the map is much better @lmotta :)

@lmotta

lmotta commented Oct 27, 2026

Copy link
Copy Markdown
Author

Hi @tomasMizera, thanks for the review!

To address the performance concerns, I've adjusted the approach based on your feedback:

Parallel Rendering: The current implementation uses QgsMapRendererParallelJob inside refreshMap(), running the background map rendering in worker threads without blocking the main UI thread.

Configurable Margin Ratio (MARGIN_RATIO = 0.5): To reduce the pixel rendering load compared to the initial 3.0x factor, I refactored the canvas expansion to use a configurable MARGIN_RATIO per side.

Setting MARGIN_RATIO = 0.5 adds half a screen size of margin to each side, bringing the total canvas size to 2.0x (4x pixels instead of 9x).

This reduces computational and memory demands significantly. While panning beyond half a screen in a single fast gesture will still expose the white background (just as a 1.0x factor would on fast pans), this 0.5 margin covers typical small-to-medium pan gestures while keeping background rendering work much lighter.

Regarding setPreviewJobsEnabled, I haven't tested this option yet and I'm not sure if it is supported in the mobile environment or rendering pipeline.

Please let me know if this lower margin ratio works as an acceptable compromise for the project!

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.

3 participants