I have an Ionic app that uses the latest versions of angular 4 and ionic 3.
I'm using PIXI (4.5.2) in one of the screens in it - the game screen.
The player frequently moves in and out of that screen.
Before starting the game I'm:
-Preparing resources
-Moving to game screen
-Adding the canvas (app.view) to DOM
Before moving away from the game screen I'm:
-Destroying resources and resetting the PIXI.loader
-Removing the canvas (app.view) from DOM
Most of the time everything works fine, but rarely when I'm moving away from the game screen I'm getting the following error:
QuoteRuntime Error
Cannot read property 'width' of nullStackTypeError: Cannot read property 'width' of null at Image.e.calculateVertices (http://localhost:8100/assets/imageSwapper/pixi.min.js:14:13368) at Image.e._renderWebGL (http://localhost:8100/assets/imageSwapper/pixi.min.js:14:14230) at Image.e.renderWebGL (http://localhost:8100/assets/imageSwapper/pixi.min.js:10:21822) at Swapper.e.renderWebGL (http://localhost:8100/assets/imageSwapper/pixi.min.js:10:21898) at e.renderWebGL (http://localhost:8100/assets/imageSwapper/pixi.min.js:10:21898) at e.render (http://localhost:8100/assets/imageSwapper/pixi.min.js:13:8590) at t.render (http://localhost:8100/assets/imageSwapper/pixi.min.js:10:10909) at t.emit (http://localhost:8100/assets/imageSwapper/pixi.min.js:16:7855) at t.update (http://localhost:8100/assets/imageSwapper/pixi.min.js:16:6834) at _tick (http://localhost:8100/assets/imageSwapper/pixi.min.js:16:5017) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:12256) at Object.onInvokeTask (http://localhost:8100/build/main.js:4539:37) at t.invokeTask (http://localhost:8100/build/polyfills.js:3:12177) at n.runTask (http://localhost:8100/build/polyfills.js:3:7153) at invoke (http://localhost:8100/build/polyfills.js:3:13213)
I don't know yet why this error only rarely occurs and why. What do you think?