Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
lukaszp
Power BI Team
Power BI Team

Custom Visuals Sandbox is coming - Here's what you need to know

Custom visual authors and users - we'd like you help to find the last bugs in a new feature for custom visuals - sandboxing.  We've seen a lot of great visuals be created by our community, and we've seen how some of those visual interact with each other, with our own UI elements, and with our APIs.  This has led to some glitches for users and visual authors. So we're planning to add sandboxing.  Sandboxing will be enabled in the service on or after March 22nd 2016.  

 

Asks and Acitons for custom visuals users/developers 

  1. Test your visuals using the steps shown below
  2. Review the list of Known Issues.
  3. Reply to this post with issues you find so we can investigate them.

 

 

What is sandboxing for custom visuals

Sandboxing provides a layer of isolation for each custom visual by hosting it in a dedicated iFrame.  Your code and dependencies are injected dynamically into the iFrame.  It ensures you don’t have conflicts with other visuals/elements on your page and removes access to APIs that you shouldn’t be using in your custom visuals.

 

When will Sandboxing be enabled for custom visuals?

We expect it to enabled sandboxing on or around March 22nd 2016. We’ll adjust this based on your feedback and reported issues.

 

What is the impact on my custom visual?

Sandboxing runs your visual’s code in a low privilege iFrame with no domain.  You will not be able to assume access to Power BI styles (CSS), Power BI fonts, or undocumented Power BI APIs.  We will inject all the required interfaces into the iFrame including your visual’s code.  Then we will marshal data points and required settings across the iFrame boundary.  Since the iFrame has no domain, you will not have access to cookies or local storage. Lastly, how you debug your custom visual will change a little, which I’ll cover below.

Here’s an example iFrame that your visual would be loaded into:

<iframe class="visual-sandbox" src="/sandbox?plugin= MyVisualName" style="width: 1177px; height: 682.04px;" sandbox="allow-scripts"></iframe>

 

How can I test my visual in the Sandbox?

Starting now you can test your visuals, dashboards, and reports in the sandbox by adding the following flag to the URL in the address bar.

Follow these steps:

  • Sign-in to your Power BI account
  • Paste the following URL into your browser address bar

https://app.powerbi.com/?sandboxVisualsEnabled=1

 

  • Press enter to navigate to the URL above
  • You know the feature switch successfully applied if after the browser loads the flag is in the URL. For example:

https://app.powerbi.com/groups/me/dashboards/5f3627e4-a662-4111-a5ea-39ef2833fe24?sandboxVisualsEnab...

 

  • Please note that if you needed to sign-in in step #2, the feature switch will not be applied. You can click the URL again, or just paste ?sandboxVisualsEnabled=1 on the URL and refresh.

 

How do I debug in the sandbox?

To debug, the easiest way is to add the following line of code to your visual’s init method or wherever you’d like a breakpoint for the browser’s debugger.

 

debugger;

 

Then, when you’d like to debug your visual, launch the browser’s debugger, add your visual to the page and bind some data to it.  The debugger will automatically break when init is called by Power BI allowing you to see your code.  Without this, you may find it hard to identify where the code is located in the browser’s debugger since it is dynamically injected into the iFrame.

 

A note about unhandled exceptions

One thing that is important for you to add to your visuals is some hardening for unhandled exceptions. To keep the iframe and the host page in sync, we run synchronization code in the iFrame alongside your visual’s code.  If your visual throws an unhandled exception, we attempt to catch it so our synchronization code keeps working. Even then, your code might not work in the resulting state. We’ve found that some custom visuals have unpredictable behaviors after they throw an unhandled exception. Unfortunately, since it’s your code we’re not able to fix those issues on our side. The most common symptom of this is the visual stops resizing correctly when the user resizes the visual in Power BI.  If you see this happening, check if the custom visual is throwing exceptions and resolve those before submitting an issue.

 

Known issues

Here's a list of known bugs we're tracking:

1) Sometimes the visual does not resize in the iFrame.  Usually this is due to an unhandled exception in the visual, but sometmies it's the framework. We're working on a fix. Your code should trap it's exceptions to avoid one of the major causes.

2) Fonts and CSS styles.  Some visuals depend on Fonts and CSS from Power BI.  Not all styles are available within the sandbox.  You will not have access to Power BI's fonts in the iFrame.  Please adjust the code of your visual to use specific and predictable Fonts and CSS.

2) iFrame within custom visuals are blocked.  This is feature is due to the sandbox security policies we set.  You should updated your code not to use an iFrame.

3) Performance for loading custom visuals.  The is an impact due to the sandbox for how fast cusotm visuals load. We are working on fixes to make this better and some features to make it better still. 

79 REPLIES 79

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.