I ran into this same problem using a shortcode I wrote for a custom theme. The shortcode includes a line where I set a variable to get_the_excerpt(). With that inline in the code and my shortcode in use, the TOC is not generated on that page. If I comment out that single line from my code, the TOC is generated as expected.