Question
We're experiencing a critical issue with our web application on Samsung Tizen TVs (2015-2016 models). The problem occurs under the following circumstances:
- The app is running normally
- The TV is turned off and then back on
- When reopening the app (which maintains its previous state due to multitasking)
After this sequence:
- All animations using VelocityJS stop working
- Menus become overlapped and unusable
- CSS animations continue to work normally
Important Notes:
- The issue only occurs after TV power cycling, not when switching between apps
- We're using the
visibilitychangeevent listener for multitasking management - The problem is specific to VelocityJS animations
This is a critical production issue affecting our users. Any guidance on resolving this would be greatly appreciated.
Answer
Problem Understanding
The core issue appears to be related to how VelocityJS animations are handled during TV power cycles. The visibilitychange event is triggered correctly, but VelocityJS fails to resume animations properly after power cycling.
Solution Methods
-
Power Event Handling:
- Register for power button events in addition to visibility changes
- Add
tv.inputdeviceprivilege to your config file - Implement event listeners for power-related events
-
VelocityJS Reinitialization:
- Force reinitialize VelocityJS when the app regains visibility
- Store animation states and reapply them after power cycles
-
Fallback to CSS Animations:
- Consider implementing CSS animation fallbacks for critical UI elements
- Use feature detection to switch between VelocityJS and CSS animations
Code Examples
// Power key event handling
document.addEventListener('keydown', function(e) {
if (e.keyCode === 10252) { // Power key code
// Handle power off event
saveAnimationStates();
}
});
// Visibility change handling
document.addEventListener('visibilitychange', function() {
if (!document.hidden) {
// App is visible again
reinitializeVelocityJS();
restoreAnimationStates();
}
});
Additional Tips
- Test thoroughly on both 2015 and 2016 TV models
- Consider logging animation states for debugging
- Monitor memory usage as improper cleanup might contribute to the issue
- For reference, check the updated documentation at Samsung Tizen OS Developer Portal