I understand you're experiencing a WebGL context loss issue with the Spine Web Player on Samsung phones. This is a common problem on mobile devices where the browser reclaims WebGL contexts to free up resources.
Here are several solutions to address this issue:
1. Enable context restoration
Add the preserveDrawingBuffer configuration option to your SpinePlayer:
new spine.SpinePlayer("player-container", {
skeleton: "path/to/skeleton.json",
atlas: "path/to/atlas.atlas",
preserveDrawingBuffer: true,
// ... other configuration
});
2. Reduce memory usage
Mobile devices, especially Samsung phones, are more aggressive about reclaiming WebGL contexts. Try these optimizations:
- Use smaller texture atlas sizes
- Enable premultiplied alpha to reduce memory usage:
new spine.SpinePlayer("player-container", {
skeleton: "path/to/skeleton.json",
atlas: "path/to/atlas.atlas",
premultipliedAlpha: true,
// ... other configuration
});
3. Pause rendering when not visible
If the player is off-screen or the page is in the background, pause it to reduce resource usage. This can help prevent context loss.
4. Handle context loss gracefully
Unfortunately, once a WebGL context is lost, the player needs to be recreated. You may need to implement your own context loss handler at the application level.
5. Reduce background color complexity
If you're using a translucent player with alpha: true, this can increase memory pressure:
new spine.SpinePlayer("player-container", {
skeleton: "path/to/skeleton.json",
atlas: "path/to/atlas.atlas",
alpha: false, // Try making it opaque
backgroundColor: "#666666",
// ... other configuration
});
The Samsung browser is known to be particularly aggressive with WebGL context management on lower-end devices or when memory is constrained. The solutions above should help mitigate the issue.