locked
Possible bug in Navigator / FlipView control?

    Question

  • Hi,

    I've been tracking down an error in my application that made me (almost) pull my hair off.
    One page in the application has a FlipView control that shows several images. The client wants to cycle through them automatically. I haven't found a property/method in FlipView's documentation to do this so I implemented it using setInterval + FlipView.next() / FlipView.previous()

    The problem I'm having is that if I navigate to another page (e.g. click back button) an instant after the new page (image) has been rendered, the application crashes at base.js.
    I confirmed that when the app crashes the FlipView's PageCompleted event hasn't been triggered yet.

    Seems like the FlipView control hasn't finished doing its job and the Navigator kill the current page.
    I've tryed wrapping the navigation code around msSetImmediate but this hasn't helped.

    Is this a known bug?

    Thanks,
    Diego.


    • Edited by Diego Ledesma Tuesday, July 24, 2012 2:32 PM add more information
    Tuesday, July 24, 2012 2:23 PM

All replies

  • Do you clear your flip interval before you navigate?

    WinJS.Navigation.addEventListener("beforenavigate", onbeforeNavigate);
    
        function onbeforeNavigate(eventObject) {    
            // Clear the flipview interval
            clearInterval(_flipInterval);
            // We only want this to run on this page
            WinJS.Navigation.removeEventListener("beforenavigate", onbeforeNavigate); 
        }

     
    Tuesday, July 24, 2012 5:32 PM
  • Yes, I'm clearing the interval. Not before navigation but inside the function that runs every 6 seconds.
    Like this:

    var flipIntervalPtr = setInterval(flipAnimate,6000);
    
    function flipAnimate(){
    
    	//get the flipview control
    	var flipCtrl = document.querySelector("#flipview").winControl
    
    	if (!flipCtrl){
    	//control wasn't found. Tipically because the user navigated out of the page that the function runs on.
    	//remove the interval and quit function execution
    	clearInterval(flipIntervalPtr);
    	return false;
    }
    
    //do flipping animation
    
    }

    The app crashes as soon as I click the back button (which is also as soon as the flipAnimate function is executed).
    The workaround I've found for now is delaying the navigation 250 miliseconds using setTimeOut.

    The error message is "Unable to get property 'insertBefore' of undefined or null reference" at base.js line 6220

    Thanks.

    Wednesday, July 25, 2012 2:18 PM
  • Hi,

    It would be better if you can share your demo project via SkyDrive, then we can find the issue more conveniently and provide further suggestions to you.

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework

    Monday, July 30, 2012 2:12 PM
    Moderator
  • Hi!

    I have been facing similar problems with FlipView for c#

    it seems to crash after certain intervals. Is there any solution to this issue?

    Thursday, September 13, 2012 7:22 AM