Bug 415747 - Phantom off-canvas content with vector objects
Summary: Phantom off-canvas content with vector objects
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Layers/Vector (show other bugs)
Version: nightly build (please specify the git hash!)
Platform: Debian stable Linux
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-31 15:41 UTC by Ahab Greybeard
Modified: 2020-03-10 11:32 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Simple image file for convenient use (484.67 KB, application/x-krita)
2019-12-31 15:41 UTC, Ahab Greybeard
Details
Screenshots of moving and trimming (51.04 KB, image/png)
2019-12-31 19:25 UTC, Rebecca Breu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ahab Greybeard 2019-12-31 15:41:07 UTC
Created attachment 124814 [details]
Simple image file for convenient use

SUMMARY
This happens with the 4.2.8 and the Dec28 4.3.0 prealpha (git 3f0ff1a) appimages and the Windows portable .zip packages.
It does not happen with version 4.2.6 or 4.2.7.1
However, see Additional Notes.

If a vector object is moved off-canvas and then moved back on-canvas, phantom content is created off-canvas at the location where the object was moved to. This content can be seen on the layer thumbnail and is included in the Move Tool content bounding box.
It has an effect on the Trim operations and it affects .svg export.
It is removed when the image is Saved.

I attach a simple .kra file that can be used for convenience to demonstrate the problem.

STEPS TO REPRODUCE
1. Open two-vector-objects.kra and use the Move tool to note that the extent of content is limited to the circle and the rectangle on the canvas, as expected.
2. Zoom out a little so there is a good amount of off-canvas area on the workspace, for ease of further manipulation.

3. Use the Select Shapes Tool to move the circle left to an off-canvas location, then click on the canvas to clear the object selection.
4. Use the Move Tool to check the extent of content and note that it includes the off-canvas circle, as would be expected.
At this stage, the layer thumbnail will have been updated to show the circle and rectangle.

5. Use the Shapes Select Tool to move the rectangle close to the left edge of the canvas, to get the shapes close together for convenience during the next steps.
6. Use the Move Tool to move the rectangle and circle into the middle of the canvas then press ruturn to finalise the move.
Note that the layer thumbnail shows a 'phantom' red circle off-canvas to the left.

7. Use the Move Tool again and Note that the extent of content includes the phanton red circle off-canvas to the left.
Move the content to the right so that the rectangle moves off canvas to the right and note that there is nothing visible at the left side of the content bounding box.

8. Move the content back to the left so that the rectangle and circle are in the middle again.
Note that the layer thumbnail shows a complete or partial rectangle off-canvas the the left.
Note that the Move Tool now indicates there is content off-canvas to the right.

9. Do Image -> Trim To Image Size and Note that this has no effect on the phantom off-canvas content.
10. Do Layer -> Import/Export -> Save Vector Layer As SVG and save the .svg file.

11. Do File -> New and make a new 2048 x 2048 image then do Layer -> Import/Export -> Import Layer and open the saved .svg file.
Note that the circle and rectangle are badly offset. i.e, the phantom content has affected the .svg export.
Close this new image without saving it, that was only for demonstration.

12. Do Image -> Trim to Current Layer and Note that the trim action is affected by and takes account of the phantom off-canvas content.
13. Do Undo Crop (trim) Image to restore the original image size.
14. Do File -> Save then close the open image and then File -> Open to open it again.
Note that the phantom content is now gone.

OBSERVED RESULT
See Steps to Reproduce

EXPECTED RESULT
The phantom content should not exist.

ADDITIONAL INFORMATION
With 4.2.6, phantom content is not created but the Move tool bounding box does not include genuine off-canvas content. However, the Move Tool will cause genuine off-canvas content to move.

With 4.2.7.1, there is temporary phantom off-canvas content as shown by the layer thumbnail but this goes away when the Move Tool is used again after moving the circle back on-canvas.

SOFTWARE/OS VERSIONS
Krita

 Version: 4.3.0-prealpha (git 3f0ff1a)
 Languages: en_GB, en, en, en_GB, en
 Hidpi: true

Qt

  Version (compiled): 5.12.5
  Version (loaded): 5.12.5

OS Information

  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 4.19.0-6-amd64
  Pretty Productname: Debian GNU/Linux 10 (buster)
  Product Type: debian
  Product Version: 10

OpenGL Info
 
  Vendor:  "NVIDIA Corporation" 
  Renderer:  "GeForce GTX 750 Ti/PCIe/SSE2" 
  Version:  "4.6.0 NVIDIA 418.74" 
  Shading language:  "4.60 NVIDIA" 
  Requested format:  QSurfaceFormat(version 3.0, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
  Current format:    QSurfaceFormat(version 4.6, options QFlags<QSurfaceFormat::FormatOption>(DeprecatedFunctions), depthBufferSize 24, redBufferSize 8, greenBufferSize 8, blueBufferSize 8, alphaBufferSize 8, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::DoubleBuffer, swapInterval 0, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::CompatibilityProfile) 
     Version: 4.6
     Supports deprecated functions true 
     is OpenGL ES: false 

QPA OpenGL Detection Info 
  supportsDesktopGL: true 
  supportsOpenGLES: true 
  isQtPreferOpenGLES: false 

Hardware Information

  GPU Acceleration: auto
  Memory: 16039 Mb
  Number of Cores: 8
  Swap Location: /tmp

Current Settings

  Current Swap Location: /tmp
  Undo Enabled: 1
  Undo Stack Limit: 18
  Use OpenGL: 1
  Use OpenGL Texture Buffer: 1
  Use AMD Vectorization Workaround: 0
  Canvas State: OPENGL_SUCCESS
  Autosave Interval: 360
  Use Backup Files: 1
  Number of Backups Kept: 1
  Backup File Suffix: ~
  Backup Location: Same Folder as the File
  Use Win8 Pointer Input: 0
  Use RightMiddleTabletButton Workaround: 0
  Levels of Detail Enabled: 0
  Use Zip64: 0
Comment 1 Rebecca Breu 2019-12-31 19:24:11 UTC
I can confirm this. I also noticed:

1. Undoing the move operation doesn't remove the artifacts
2. When I initially move one object outside the canvas, it only gets shown partly in the preview, and trimming the image to the layer at that stage only includes that part of my object too. After this trimming, my preview has this image duplicated, and trimming again (without doing anything else in between) makes the image bigger again in accordance with the preview but without any new content showing up.
Comment 2 Rebecca Breu 2019-12-31 19:25:42 UTC
Created attachment 124815 [details]
Screenshots of moving and trimming
Comment 3 Halla Rempt 2020-01-03 13:56:08 UTC
I'll assign this to Dmitry, but it'll be a while before we can have a fix, since he's on parental leave right now.
Comment 4 Dmitry Kazakov 2020-03-10 11:32:41 UTC
Git commit 1b60a6c1fc3e763e94f9ed9c70841bc636d88568 by Dmitry Kazakov.
Committed on 10/03/2020 at 11:32.
Pushed by dkazakov into branch 'master'.

Fix phantom off-canvas leftovers of shapes on shape layers

We should clear projection content that was cropped by image bounds
and which was changed by the shape movements.

M  +4    -1    libs/flake/KoShapeManager.h
M  +6    -1    libs/ui/flake/kis_shape_layer_canvas.cpp

https://invent.kde.org/kde/krita/commit/1b60a6c1fc3e763e94f9ed9c70841bc636d88568