19 Replies Latest reply on Aug 11, 2009 9:26 PM by flex Creek

    Security Sandbox Violation on HDividedBox resize

      This is being run in flex debugger as an Air app. I've got 2 tilelists with images loaded from the filesystem by setting the source property to the url of the local files.  The tile lists are in an HDividedBox.  Resizing the gutter on the HDiv Box gives a Security Sandbox Violation.

       

      I've included a minimal self contained mxml test case.

       

      Why do I get a sanbox violation when resizing the HDividedBox?

       

      I seem to be getting the same violation when trying to drag the icons.

       

      I get that the images are loading data in a seperate security context from the app: context, but how is dragging the HDiv box causing any conflicts?

       

      I am baffeled as to why either one is giving my a sandbox violation.

       

      Any pointers?

       

      [CODE]
      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
                              layout="absolute"
                              initialize="fillList()" >
                             
          <mx:HDividedBox x="0" y="0" width="100%" height="100%">
              <mx:TileList width="100%" height="100%" dataProvider="{imageFiles}" dragEnabled="true">
                  <mx:itemRenderer><mx:Component>
                      <mx:Image source="{data}" />
                  </mx:Component></mx:itemRenderer>
              </mx:TileList>
              <mx:TileList width="100%" height="100%" dataProvider="{imageFiles}" dragEnabled="true">
                  <mx:itemRenderer><mx:Component>
                      <mx:Image source="{data}" />
                  </mx:Component></mx:itemRenderer>
              </mx:TileList>
          </mx:HDividedBox>
         
          <mx:Script>
              <![CDATA[
             
      [Bindable]
      private var imageFiles:Array = new Array()
             
      public function fillList():void {
             var directory:File = new File("C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures");
             var files:Array = directory.getDirectoryListing();
         
          for each (var f:File in files)
          {
                if (f.name.match(/.jpg$/i)) {
                  imageFiles.push(f.url);
                }
          }
      }
              ]]>
      </mx:Script>

       

      </mx:WindowedApplication>

       

      [/CODE]

        • 2. Re: Security Sandbox Violation on HDividedBox resize
          Level 1

          I can't just ignore the messages, because they are filling up my console, and making all of my trace messages useless.

           

          Seriously, I would consider such a glib answer being given to a legitimate issue by a developer of my product grounds for termination, or at least some major attitude adjustment.

          • 3. Re: Security Sandbox Violation on HDividedBox resize
            flex Creek

            jeffputney I have the same problem as you

             

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:WindowedApplication creationComplete="init()" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="588" height="522">
                  <mx:Script>
                    <![CDATA[
                        private function init():void
                        {
                                //Security.allowDomain("*");
                        }
                    ]]>
                </mx:Script>
                <mx:HDividedBox width="100%" height="100%">
                        <mx:Button id="test"></mx:Button>
                        <mx:Image source="http://www.epopos.com/os.jpg"/>
                </mx:HDividedBox>
            </mx:WindowedApplication>
            Above is a simple code of the air.It's mainly load a picture from network.The picture can be displayed normally.
            But when we drag the HDividedBox will produce Security Sandbox Violation.
            like this 
            *** Security Sandbox Violation *** 
            SecurityDomain 'http://www.epopos.com/os.jpg' tried to access incompatible context 'app: / Test.swf' 
            *** Security Sandbox Violation *** 
            SecurityDomain 'http://www.epopos.com/os.jpg' tried to access incompatible context 'app: / Test.swf' 
            Flex Application for the same code. We can use 'Security.allowDomain ("*");' to solve this problem. 
            However, We cann't use Security.allowDomain ("*") in Air.It will produce SecurityError.
            Analysis: ???
            The reason of produced the problem is than  when we drag the HDividedBox led to 'os.jpg' access air.But air doesn't allow it.
            Test solution: ? ?      Adodb's SandboxBridge is aim to solve that air and a remote swf internal communication problems, but it still substantial differences between them, so this option will do not work. ??
                   This issue has nothing to do with crossdomain.xml, Air doesn't access crossdomain.xml,Air can access any resources from network in default. 
                  Air access resources from netword is a normal, and if this problem is not solved,when we drag HDvideBox will lead to beef-witted or even stuck
            DataGird is the same problem, I do not know whether it'is the flex bug,
            I have searched a large number of articles,but is not be resolved, I hope someone can help me .Thank you Very much.

            • 4. Re: Security Sandbox Violation on HDividedBox resize
              Flex harUI Adobe Employee

              You might try putting a transparent shield over the image.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              • 5. Re: Security Sandbox Violation on HDividedBox resize
                flex Creek Level 1

                Flex harUI  Thank you for your help.

                 

                 

                 

                But I can't understand what's meaning of 'transparent shield'. Could you tell me the detail what should I do.

                 

                If the Image is from other website .and I cann't control It .how can I put a transparent shield over the image. and maybe it is a swf.

                 

                Look forward to your reply to further . Thanks again

                • 6. Re: Security Sandbox Violation on HDividedBox resize
                  Flex harUI Adobe Employee

                  Put the Image in a Canvas.  Put another Canvas over it with a backgroundColor and alpha=0.

                   

                  There are more efficient ways involving UIComponent, but see if that works.

                   

                  Alex Harui

                  Flex SDK Developer

                  Adobe Systems Inc.

                  Blog: http://blogs.adobe.com/aharui

                  • 7. Re: Security Sandbox Violation on HDividedBox resize
                    flex Creek Level 1

                    Hi Flex harUI !


                    <?xml version="1.0" encoding="utf-8"?>
                    <mx:WindowedApplication creationComplete="init()" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="588" height="522">
                        <mx:HDividedBox id="divided" width="100%" height="100%">
                            <mx:VBox width="300" height="100%">
                                <mx:HSlider thumbCount="" width="100%"/>
                                <mx:DataGrid width="100%">
                                    <mx:columns>
                                        <mx:DataGridColumn headerText="month" dataField="Month" width="100" textAlign="center"/>
                                        <mx:DataGridColumn headerText="times" dataField="Count"  width="100"  textAlign="center"/>
                                        <mx:DataGridColumn headerText="percent" textAlign="left"></mx:DataGridColumn>
                                    </mx:columns>   
                                </mx:DataGrid>
                            </mx:VBox>
                            <mx:Canvas width="100%" height="100%">
                                <mx:Image source="http://www.epopos.com/os.jpg" scaleContent="false"/>
                                   <mx:Canvas width="100%" height="100%"  alpha="0"/>
                            </mx:Canvas>
                           
                        </mx:HDividedBox>
                    </mx:WindowedApplication>

                     

                    I have done it In accordance with your advice. But it do not work.

                    I post the code again.When the mouse is in a dragging state  the we click and release the mouse will produce the problem.

                    HSlider and DataGrid have the same problem.

                    If we create a new Window. then add a HDividedBox as child to the window. the Image add to the parent window. When we resize the HDividedBox The problem still exists.

                    If you have a time. Maybe you can try to run do code.

                    thanks again.

                    • 8. Re: Security Sandbox Violation on HDividedBox resize
                      Flex harUI Adobe Employee

                      Try something like:

                       

                      <mx:Canvas width="100%" height="100%">

                                  <mx:Image source="http://www.epopos.com/os.jpg" scaleContent="false"/>

                                     <mx:Canvas width="100%" height="100%" backgroundColor="0xffffff"  alpha="0"/>

                              </mx:Canvas>

                       

                      Set alpha=1 just to make sure it covers the image, then set it back to 0 and see if you still get the error.

                       

                      Alex Harui

                      Flex SDK Developer

                      Adobe Systems Inc.

                      Blog: http://blogs.adobe.com/aharui

                      • 9. Re: Security Sandbox Violation on HDividedBox resize
                        flex Creek Level 1

                        <mx:Canvas width="300" height="300">
                                    <mx:Image source="http://www.epopos.com/os.jpg" scaleContent="false" />
                                       <mx:Canvas width="300" height="300"  alpha="0" backgroundColor="#ffffff"/>
                                </mx:Canvas>

                         

                        I have changed the Image's size to 293*211.  where alpha="0". I'm sure I cann't see the Image. then change alpha="0".

                         

                        But when I debug the app. I do nothing. I will see the error.

                         

                        *** Security Sandbox Violation ***
                        SecurityDomain 'http://www.epopos.com/os.jpg' tried to access incompatible context 'app:/AirTest.swf'

                         

                         

                         

                         

                        Cloud tell me why?  I do not think there is the relationship between it and the  crossdomain.xml.

                         

                        <?xml version="1.0" encoding="UTF-8" ?>
                        <!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
                        <cross-domain-policy>
                            <site-control permitted-cross-domain-policies="master-only"/>
                            <allow-access-from domain="*" />
                        </cross-domain-policy>

                         

                         

                        Thank you!

                        • 10. Re: Security Sandbox Violation on HDividedBox resize
                          flex Creek Level 1

                          I test it again just now.

                           

                          <mx:HBox width="300" height="300">
                                      <mx:Image source="http://www.epopos.com/os.jpg" scaleContent="false" />
                                  </mx:HBox>

                           

                          1.when set scaleContent="false" then debug the app and do nothing. it will display error .drag HDividedBox. display error also.

                          2.Set scaleContent="true" then debug the app and do nothing .It will be normal.but drag HDividedBox. it shows error again.

                          3.Put the Image in HDividedBox  without HBox.Whether set scaleContent true or false. then debug the app and do nothing.It will be normal.but drag HDividedBox. it will show error.

                          • 11. Re: Security Sandbox Violation on HDividedBox resize
                            Flex harUI Adobe Employee

                            You'll often see warnings in the debug output.  They can be ignored as long as you don't get an error dialog that stops the application.

                             

                            I'm unclear whether you are still seeing the error dialog when resizing the HDividedBox.

                             

                            Alex Harui

                            Flex SDK Developer

                            Adobe Systems Inc.

                            Blog: http://blogs.adobe.com/aharui

                            • 12. Re: Security Sandbox Violation on HDividedBox resize
                              flex Creek Level 1

                              Hi!

                               

                                 This is just a simple code.The warnings can be ignored.

                               

                                But I have a complex application.it may  load a lot of resources from network.Warning  can not be ignored at this time, they may lead to the slow process  or even stuck.

                               

                                thanks

                              • 13. Re: Security Sandbox Violation on HDividedBox resize
                                flex Creek Level 1

                                "I'm unclear whether you are still seeing the error dialog when resizing the HDividedBox."

                                 

                                Sorry. Maybe I say something wrong.  Just warnings not error dialog.

                                 

                                *** Security Sandbox Violation ***
                                SecurityDomain 'http://www.epopos.com/os.jpg' tried to access incompatible context 'app:/AirTest.swf'
                                *** Security Sandbox Violation ***
                                SecurityDomain 'http://www.epopos.com/os.jpg' tried to access incompatible context 'app:/AirTest.swf'
                                *** Security Sandbox Violation ***
                                SecurityDomain 'http://www.epopos.com/os.jpg' tried to access incompatible context 'app:/AirTest.swf'

                                • 14. Re: Security Sandbox Violation on HDividedBox resize
                                  Flex harUI Adobe Employee

                                  The release player, which most folks use, doesn't spit these warnings and won't be slowed by them.  If it is a problem for you in development, it might be worth analyzing and seeing if the number of warnings can be reduced.

                                   

                                  Alex Harui

                                  Flex SDK Developer

                                  Adobe Systems Inc.

                                  Blog: http://blogs.adobe.com/aharui

                                  • 15. Re: Security Sandbox Violation on HDividedBox resize
                                    flex Creek Level 1

                                    Thank you for your enthusiastic help.
                                    I have done  a test in my application.(Air)
                                    1.Loaded any resources from network. then import the release version and Install it.Run the app.Then  draging datagrid.It will work very well.
                                    2.Loaded some resources from network.Repeat the above operation.But when draging datagird.It will be slowed by something. Maybe the warnings.

                                     

                                    I have analyzed two days.and have read many articles.done many tests. I do not understand why the warnings be generated.I can not confirm whether it's a bug. or I have a probelm in somewhere.

                                     

                                     

                                    The following picture is my application's main interface

                                    mai.jpg

                                    • 16. Re: Security Sandbox Violation on HDividedBox resize
                                      Flex harUI Adobe Employee

                                      If you are not happy with the performance of your application, use the Profiler to see what is taking the most time.

                                       

                                      Alex Harui

                                      Flex SDK Developer

                                      Adobe Systems Inc.

                                      Blog: http://blogs.adobe.com/aharui

                                      • 17. Re: Security Sandbox Violation on HDividedBox resize
                                        flex Creek Level 1

                                        After I export to release version.I cann't use Profiler .

                                         

                                        But when I debug my app. Security Sandbox Violation will be caused by draging datagrid .and the warnings are filling up my console.

                                        I cann't use the mouse until the warnings stop.

                                         

                                        Maybe If I kown the reason that why the Security Sandbox Violation was caused.And solve this problem. everything will be ok.

                                         

                                         

                                        <?xml version="1.0" encoding="utf-8"?>
                                        <mx:WindowedApplication  creationComplete="init()" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="588" height="522">
                                            <mx:HDividedBox  id="divided" width="100%" height="100%">
                                                <mx:VBox width="300"  height="100%">
                                                    <mx:HSlider thumbCount=""  width="100%"/>
                                                    <mx:DataGrid  width="100%">
                                                        <mx:columns>
                                                             <mx:DataGridColumn headerText="month" dataField="Month" width="100"  textAlign="center"/>
                                                            <mx:DataGridColumn  headerText="times" dataField="Count"  width="100"   textAlign="center"/>
                                                            <mx:DataGridColumn  headerText="percent"  textAlign="left"></mx:DataGridColumn>
                                                         </mx:columns>   
                                                    </mx:DataGrid>
                                                 </mx:VBox>
                                                <mx:Canvas width="300" height="300">
                                                    <mx:Image  source="http://www.epopos.com/os.jpg" scaleContent="false" />
                                                       <mx:Canvas width="300"  height="300"  alpha="0" backgroundColor="#ffffff"/>
                                                 </mx:Canvas>
                                               
                                             </mx:HDividedBox>
                                        </mx:WindowedApplication>

                                        • 18. Re: Security Sandbox Violation on HDividedBox resize
                                          Flex harUI Adobe Employee

                                          Does it only spit warning when you drag over the Image?

                                           

                                          Alex Harui

                                          Flex SDK Developer

                                          Adobe Systems Inc.

                                          Blog: http://blogs.adobe.com/aharui

                                          • 19. Re: Security Sandbox Violation on HDividedBox resize
                                            flex Creek Level 1

                                            <?xml version="1.0" encoding="utf-8"?>
                                            <mx:WindowedApplication  creationComplete="init()" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="688" height="522">
                                                <mx:HDividedBox  id="divided" width="100%" height="100%">
                                                    <mx:VBox width="300"  height="100%">
                                                        <mx:HSlider thumbCount=""  width="100%"/>
                                                        <mx:DataGrid  width="100%">
                                                            <mx:columns>
                                                                 <mx:DataGridColumn headerText="month" dataField="Month" width="100"  textAlign="center"/>
                                                                <mx:DataGridColumn  headerText="times" dataField="Count"  width="100"   textAlign="center"/>
                                                                <mx:DataGridColumn  headerText="percent"  textAlign="left"></mx:DataGridColumn>
                                                             </mx:columns>   
                                                        </mx:DataGrid>
                                                     </mx:VBox>
                                                    <mx:Canvas width="300" height="300">
                                                        <mx:Image  source="http://www.epopos.com/os.jpg" scaleContent="false" />
                                                           <mx:Canvas width="300"  height="300"  alpha="0" backgroundColor="#ffffff"/>
                                                     </mx:Canvas>
                                                   
                                                 </mx:HDividedBox>
                                            </mx:WindowedApplication>

                                             

                                             

                                            No.when I drag over the Image.any warning will be spited.


                                            But when I click the head of datagrid to sort  it. Drag the HSlider or resize HDividedBox.warning will be spited