MantisBT - Community
View Issue Details
0030654Community[OCCT] OCCT:Visualizationpublic2019-04-17 10:492019-05-16 20:28
Vico Liang 
bugmaster 
normalblock 
feedbackopen 
QT + Visual Studio 2017 UWPWindows 1010
[OCCT] 7.4.0* 
[OCCT] 7.4.0* 
0030654: Visualization - AIS_InteractiveContext::MoveTo() failed to detect objects when using VS2017
The test was done on Microsoft Window 10 UWP cases.
Build the latest code from OCCT master with VS2017 + QT5.12.2 + QTANGLE. Build my test project adopted from sample QtAndroid with several changes to make it build on UWP. Then run the application with VS2017, on simulator, device or local desktop, none works. MoveTo won't detect the objects under mouse in most cases, there are several case hit though. The attached image will demo the cases.
pload MODELING VISUALIZATION
box b 1 2 3
vclear
vinit View1
vdisplay -dispMode 1 b
vfit
if { [lindex [vmoveto 250 250] 0] != "1" } { puts "Error" }

No tags attached.
related to 0030130verified bugmaster Open CASCADE Coding Rules - MSVC 2017 gives warnings about using of std::fpos::seekpos() within RWStl 
png detect-failed.png (9,403) 2019-04-17 10:49
https://tracker.dev.opencascade.org/
png detect-ok.png (9,536) 2019-04-17 10:49
https://tracker.dev.opencascade.org/
jpg OCCT-Build-config.jpg (188,400) 2019-04-19 04:16
https://tracker.dev.opencascade.org/
? custom.bat (1,180) 2019-04-19 04:17
https://tracker.dev.opencascade.org/
jpg OCCT-MFCSamples-Modeling.jpg (120,839) 2019-04-19 04:19
https://tracker.dev.opencascade.org/
png vs2017_15.7.4_OK.png (130,904) 2019-05-14 08:58
https://tracker.dev.opencascade.org/
png vs2017_15.9.11_KO.png (124,587) 2019-05-14 08:58
https://tracker.dev.opencascade.org/
png vs2017-5.9.12.png (42,873) 2019-05-15 13:27
https://tracker.dev.opencascade.org/
Issue History
2019-04-17 10:49Vico LiangNew Issue
2019-04-17 10:49Vico LiangAssigned To => kgv
2019-04-17 10:49Vico LiangFile Added: detect-failed.png
2019-04-17 10:49Vico LiangFile Added: detect-ok.png
2019-04-17 10:52kgvNote Added: 0083815
2019-04-17 10:57Vico LiangNote Added: 0083818
2019-04-17 11:41kgvNote Added: 0083819
2019-04-17 17:10Vico LiangNote Added: 0083829
2019-04-17 18:22Vico LiangNote Added: 0083832
2019-04-18 12:51Vico LiangNote Added: 0083845
2019-04-18 22:25kgvNote Added: 0083859
2019-04-19 04:16Vico LiangFile Added: OCCT-Build-config.jpg
2019-04-19 04:17Vico LiangFile Added: custom.bat
2019-04-19 04:19Vico LiangFile Added: OCCT-MFCSamples-Modeling.jpg
2019-04-19 04:26Vico LiangNote Added: 0083860
2019-04-19 04:36Vico LiangNote Edited: 0083860bug_revision_view_page.php?bugnote_id=83860#r21060
2019-04-19 04:37Vico LiangNote Edited: 0083860bug_revision_view_page.php?bugnote_id=83860#r21061
2019-04-26 11:17kgvNote Added: 0084007
2019-04-26 11:17kgvAssigned Tokgv => Vico Liang
2019-04-26 11:17kgvStatusnew => feedback
2019-04-30 11:56Vico LiangNote Added: 0084068
2019-04-30 11:56Vico LiangAssigned ToVico Liang => kgv
2019-04-30 11:56Vico LiangStatusfeedback => assigned
2019-04-30 11:59Vico LiangNote Edited: 0084068bug_revision_view_page.php?bugnote_id=84068#r21116
2019-04-30 12:14kgvRelationship addedrelated to 0030130
2019-05-14 08:50kgvNote Added: 0084320
2019-05-14 08:55kgvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=21183#r21183
2019-05-14 08:58kgvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=21184#r21184
2019-05-14 08:58kgvFile Added: vs2017_15.7.4_OK.png
2019-05-14 08:58kgvFile Added: vs2017_15.9.11_KO.png
2019-05-14 12:00Vico LiangNote Added: 0084331
2019-05-14 14:43kgvNote Added: 0084338
2019-05-14 14:44kgvNote Added: 0084339
2019-05-14 14:44kgvAssigned Tokgv => Vico Liang
2019-05-14 14:44kgvStatusassigned => feedback
2019-05-14 14:46kgvNote Edited: 0084338bug_revision_view_page.php?bugnote_id=84338#r21186
2019-05-15 05:22Vico LiangNote Added: 0084346
2019-05-15 05:22Vico LiangAssigned ToVico Liang => kgv
2019-05-15 08:29gitNote Added: 0084347
2019-05-15 13:24Vico LiangNote Added: 0084366
2019-05-15 13:27Vico LiangFile Added: vs2017-5.9.12.png
2019-05-15 14:15kgvNote Added: 0084367
2019-05-15 14:19kgvNote Added: 0084368
2019-05-15 14:19kgvAssigned Tokgv => bugmaster
2019-05-15 14:20kgvNote Edited: 0084368bug_revision_view_page.php?bugnote_id=84368#r21199
2019-05-16 20:28kgvSummaryVisualization - AIS_InteractiveContext::MoveTo failed to detect objects under mouse on UWP => Visualization - AIS_InteractiveContext::MoveTo() failed to detect objects when using VS2017

Notes
(0083815)
kgv   
2019-04-17 10:52   
Could you please clarify if you really mean that AIS_InteractiveContext::MoveTo() doesn't detect entities (e.g. AIS_InteractiveContext::DetectedOwner() is NULL), or that you don't see dynamic highlighting in 3D Viewer?
(0083818)
Vico Liang   
2019-04-17 10:57   
I checked the result value from MoveTo, the value result is AIS_SOD_Nothing if there is no object detected, the values is AIS_SOD_OnlyOneDetected if there is object detected. So i'm sure it's not a highlighting issue.
(0083819)
kgv   
2019-04-17 11:41   
Thats weird - there is no platform-dependent code in selection routines (the only thing are window dimensions using in math), so this should be some compiler issue...
(0083829)
Vico Liang   
2019-04-17 17:10   
Microsoft Visual Studio Enterprise 2017
Version 15.9.11
VisualStudio.15.Release/15.9.11+28307.586
Microsoft .NET Framework
Version 4.7.03190

Installed Version: Enterprise

Visual C++ 2017 00369-90000-00000-AA005
Microsoft Visual C++ 2017

Application Insights Tools for Visual Studio Package 8.14.20131.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.9.04012.0
ASP.NET and Web Tools 2017

C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

JavaScript Language Service 2.0
JavaScript Language Service

JavaScript Project System 2.0
JavaScript Project System

JavaScript UWP Project System 2.0
JavaScript UWP Project System

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

MLGen Package Extension 1.0
MLGen Package Visual Studio Extension Detailed Info

NuGet Package Manager 4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/. [^]

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

TypeScript Tools 15.9.20918.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake

Visual Studio Tools for Universal Windows Apps 15.0.28307.556
The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.
(0083832)
Vico Liang   
2019-04-17 18:22   
I guess the problem related to AIS_InteractiveContext::Activate routine, not all sub-shapes of object are activated in some cases, since the detecting algorithm is accurate from the detecting result.
(0083845)
Vico Liang   
2019-04-18 12:51   
Dear KGV, The issue is reproduced on MFC samples too. I build the MFC samples with Visual Studio 2017, MoveTo can't detect the geometry objects under mouse in some cases. Could you please have a look at this on MFC samples?
(0083859)
kgv   
2019-04-18 22:25   
> MoveTo can't detect the geometry objects under mouse in some cases.
Could you please provide complete steps to reproduce for MFC with necessary modifications (if necessary), opened model, activated selection mode(s) and mouse position?

By the way:
> Build my test project adopted from sample QtAndroid with
> several changes to make it build on UWP.
I don't see such attachments to this bug, maybe you have registered another issue for this sample improvement that I have missed?
(0083860)
Vico Liang   
2019-04-19 04:26   
(edited on: 2019-04-19 04:37)
Two images OCCT-Build-config.jpg and custom.bat are enclosed to show the OCCT build configuration. And then build the MFC samples without any modification. I test the sample Modeling. I try to move mouse on screen to touch geometry object, the issue is reproduced.

>>I don't see such attachments to this bug, maybe you have registered another issue for this sample improvement that I have missed?
No attachments uploaded about my test project adapted from QtAndroid. Since this issue is reproduced in MFC samples, it's should be much easier for developer to fix bug with MFC samples rather than building codes from UWP.

(0084007)
kgv   
2019-04-26 11:17   
> I test the sample Modeling.
> I try to move mouse on screen to touch geometry object, the issue is reproduced.
Do you see the same issue with the same sample (Modeling) within last official release 7.3.0 (without re-building it)?
(0084068)
Vico Liang   
2019-04-30 11:56   
(edited on: 2019-04-30 11:59)
I installed the last official release 7.3.0 (without re-building it), it works well with the same sample (Modeling).

(0084320)
kgv   
2019-05-14 08:50   
This is a REGRESSION coming with some VS2017 compiler update.

Tried:
- VS2017 15.7.4.
  Works as expected.
- VS2017 15.9.11.
  Debug build - works as expected.
  Release build - KO.

So, it looks like a compiler optimizer bug, which should be reported to compiler developers (Microsoft) - it is very difficult to do something with compiler bugs at application level.

You can also try downgrading VS2017 or use vc140 compiler toolchain (VS2015) also coming with VS2017 (should be explicitly enabled within VS2017 installer), although I'm not sure if it is trivial to configure.
(0084331)
Vico Liang   
2019-05-14 12:00   
Even though it's just reproduced in release build, it still can't be determined a bug of compiler. There might be some issue in code, it's better to debug the issue or dump some log to see what happed.
(0084338)
kgv   
2019-05-14 14:43   
(edited on: 2019-05-14 14:46)
> it still can't be determined a bug of compiler
Nope, it is certainly a compiler bug.
Try adding the following dummy line into method BVH_BinnedBuilder::buildNode() within BVH_BinnedBuilder.hxx:
    for (Standard_Integer aSplit = 1; aSplit < Bins; ++aSplit)
    {
      // Simple SAH evaluation
      Standard_Real aCost =
        (static_cast<Standard_Real> (aSplitPlanes[aSplit].LftVoxel.Box.Area()) /* / S(N) */) * 
aSplitPlanes[aSplit].LftVoxel.Count
      + (static_cast<Standard_Real> (aSplitPlanes[aSplit].RghVoxel.Box.Area()) /* / S(N) */) * 
aSplitPlanes[aSplit].RghVoxel.Count;

      if (aCost <= aMinSplitCost)
      {
        aMinSplitCost   = aCost;
        aMinSplitAxis   = anAxis;
        aMinSplitIndex  = aSplit;
        aMinSplitBoxLft = aSplitPlanes[aSplit].LftVoxel.Box;
        aMinSplitBoxRgh = aSplitPlanes[aSplit].RghVoxel.Box;
        aMinSplitNumLft = aSplitPlanes[aSplit].LftVoxel.Count;
        aMinSplitNumRgh = aSplitPlanes[aSplit].RghVoxel.Count;
        if (!aMinSplitBoxLft.IsValid() && aMinSplitNumLft != 0) /// never actually happen
        {
          //std::cerr << "Was?\n"; ///
          throw Standard_ProgramError ("Was?"); ///
        }
      }
    }

Somehow aMinSplitBoxLft or aMinSplitBoxRgh become uninitialized BVH_Box, that should never happen (the added condition validates this).

I suppose this is somehow related to loop unrolling.
For instance, if replace "Bins" (which is a template parameter) in the loop with
> static const int aNbBins = Bins;
the bug will also go away.
This is incorrect, of course, because Bins template parameter might be different, but within particular test case it remains the same.

The bug cannot be also temporarily suppressed locally by "#pragma optimize()", because it happen in template and "#pragma optimize" has its own bug:
https://developercommunity.visualstudio.com/content/problem/104899/no-way-to-control-optimization-of-a-template-funct.html [^]

(0084339)
kgv   
2019-05-14 14:44   
I don't have much experience reporting compiler bugs, so maybe you can try reporting the issue to Microsoft engineers?
(0084346)
Vico Liang   
2019-05-15 05:22   
Why not report your analyzing above to Microsoft, it's sufficient to approve a bug of compiler. You're a genius who can identify a bug of compiler.
(0084347)
git   
2019-05-15 08:29   
Branch CR30654_debug has been created by kgv.

SHA-1: 97a4e068de4dda5946f9c7c416d4e0550ab548cf


Detailed log of new commits:

Author: kgv
Date: Wed May 15 08:21:57 2019 +0300

    0030654: Visualization - AIS_InteractiveContext::MoveTo failed to detect objects under mouse on UWP
(0084366)
Vico Liang   
2019-05-15 13:24   
It works with VS2017 Community 15.9.12.

Microsoft Visual Studio Community 2017
Version 15.9.12
VisualStudio.15.Release/15.9.12+28307.665
Microsoft .NET Framework
Version 4.7.03190
Installed Version: Community
(0084367)
kgv   
2019-05-15 14:15   
> May   14, 2019 -- Visual Studio 2017 version 15.9.12
> April 02, 2019 -- Visual Studio 2017 version 15.9.11
(0084368)
kgv   
2019-05-15 14:19   
(edited on: 2019-05-15 14:20)
Dear bugmaster,

> ** Visual Studio 2017 Developer Command Prompt v15.9.6
Could you please perform regression testing on last Visual Studio 2017 update (on dedicated workstation),
and if there no issues update Jenkins workstations used for testing accordingly?