{"action":"created","issue":{"url":"https://api.github.com/repos/HaxeFlixel/flixel/issues/2050","repository_url":"https://api.github.com/repos/HaxeFlixel/flixel","labels_url":"https://api.github.com/repos/HaxeFlixel/flixel/issues/2050/labels{/name}","comments_url":"https://api.github.com/repos/HaxeFlixel/flixel/issues/2050/comments","events_url":"https://api.github.com/repos/HaxeFlixel/flixel/issues/2050/events","html_url":"https://github.com/HaxeFlixel/flixel/issues/2050","id":219012834,"number":2050,"title":"Invalid Bitmap Error when removing glow Filter from a FlxSprite","user":{"login":"sano98","id":8257477,"avatar_url":"https://avatars1.githubusercontent.com/u/8257477?v=3","gravatar_id":"","url":"https://api.github.com/users/sano98","html_url":"https://github.com/sano98","followers_url":"https://api.github.com/users/sano98/followers","following_url":"https://api.github.com/users/sano98/following{/other_user}","gists_url":"https://api.github.com/users/sano98/gists{/gist_id}","starred_url":"https://api.github.com/users/sano98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sano98/subscriptions","organizations_url":"https://api.github.com/users/sano98/orgs","repos_url":"https://api.github.com/users/sano98/repos","events_url":"https://api.github.com/users/sano98/events{/privacy}","received_events_url":"https://api.github.com/users/sano98/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-03T17:56:29Z","updated_at":"2017-04-03T20:19:13Z","closed_at":null,"body":"- **Haxe version:** 3.3.0-RC1\r\n- **Flixel version:** 4.2.0\r\n- **OpenFL version:** 3.6.1\r\n- **Lime version:** 2.9.1\r\n- **Affected targets:** Flash\r\n\r\n________________________________\r\n\r\n**Code snippet reproducing the issue**:\r\n\r\n```haxe\r\npackage;\r\n\r\nimport flixel.FlxG;\r\nimport flixel.FlxSprite;\r\nimport flixel.FlxState;\r\nimport flixel.graphics.FlxGraphic;\r\nimport flixel.system.FlxAssets.GraphicLogo;\r\nimport flixel.graphics.frames.FlxFilterFrames;\r\nimport flash.filters.BitmapFilter;\r\nimport flash.filters.GlowFilter;\r\n\r\n\r\n/**\r\n * Test project for button glow filter.\r\n * Press \"G\" on the keyboard to toggle the glow over the flixel icon.\r\n * Removing the glow without the presence of the buffer sprite causes an Invalid Bitmap Error.\r\n * Written by sano98.\r\n * \r\n */\r\n\r\n \r\nclass PlayState extends FlxState\r\n{\r\n\t/**\r\n\t * The test sprite. Press \"G\" to give it a glow, and again to remove it.\r\n\t */\r\n\tpublic var testIcon:FlxSprite;\r\n\t\r\n\t\r\n\t/**\r\n\t * The \"buffer sprite\". It's presence keeps the bug from happening.\r\n\t */\r\n\tpublic var testIcon2:FlxSprite;\r\n\t\r\n\t/**\r\n\t * Glow Filter for the flixel icon\r\n\t */\r\n\tpublic var glowFilter:GlowFilter;\r\n\tpublic var filterFrame:FlxFilterFrames;\r\n\t\r\n\t\r\n\t\r\n\t\r\n\toverride public function create():Void\r\n\t{\r\n\t\tFlxG.worldBounds.set( 0, 0, 640, 480); \r\n\t\tFlxG.camera.setScrollBoundsRect(0, 0, 640, 480, false);\r\n\t\t\r\n\t\t\r\n\t\tsuper.create();\r\n\t\t\r\n\t\tthis.bgColor = 0xFF77AAFF;\r\n\t\t\r\n\t\tthis.testIcon = new FlxSprite(300, 300, FlxGraphic.fromClass(GraphicLogo));\r\n\t\tthis.add(this.testIcon);\r\n\t\t\r\n\t\t\r\n\t\t//Comment this line out to reproduce the bug.\r\n\t\tthis.testIcon2 = new FlxSprite(300, 300, FlxGraphic.fromClass(GraphicLogo));\r\n\t\t\r\n\t\t\r\n\t\tthis.glowFilter = new GlowFilter(0xFFFFFFFF, 0.8, 5, 5, 3);\r\n\t\tthis.filterFrame = this.createFilterFrames(this.testIcon);\r\n\t\t\r\n\r\n\t\t\r\n\t}\r\n\t\r\n\t\r\n\tprivate function createFilterFrames(sprite:FlxSprite):FlxFilterFrames\r\n\t{ \r\n\t\tvar filterFrames = FlxFilterFrames.fromFrames(sprite.frames, 5, 5, []); \r\n\t\treturn filterFrames; \r\n\t} \r\n\t\r\n\t\r\n\tfunction updateFilter(spr:FlxSprite, sprFilter:FlxFilterFrames)\r\n\t{\r\n\t\tsprFilter.applyToSprite(spr, false, true);\r\n\t}\r\n\t\r\n\r\n\t\r\n\toverride public function update(elapsed:Float):Void\r\n\t{\r\n\t\tsuper.update(elapsed);\r\n\t\t\r\n\t\t\r\n\t\t\r\n\t\tif (FlxG.keys.justPressed.G)\r\n\t\t{\r\n\t\t\tif (this.filterFrame.filters.length > 0)\r\n\t\t\t{\r\n\t\t\t\tthis.filterFrame.clearFilters();\r\n\t\t\t\tthis.updateFilter(testIcon, this.filterFrame);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.filterFrame.addFilter(glowFilter);\r\n\t\t\t\tthis.updateFilter(testIcon, this.filterFrame);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n```\r\n\r\n________________________________\r\n\r\n**Observed behavior:**\r\nWhen the testIcon2 is not initialised, the code crashs with an invalid bitmap error when pressing the \"G\"-Button on the keyboard for the second time.\r\n\r\n**Expected behavior:**\r\nPressing G should simply toggle the glow.\r\n"},"comment":{"url":"https://api.github.com/repos/HaxeFlixel/flixel/issues/comments/291261363","html_url":"https://github.com/HaxeFlixel/flixel/issues/2050#issuecomment-291261363","issue_url":"https://api.github.com/repos/HaxeFlixel/flixel/issues/2050","id":291261363,"user":{"login":"Gama11","id":2620907,"avatar_url":"https://avatars3.githubusercontent.com/u/2620907?v=3","gravatar_id":"","url":"https://api.github.com/users/Gama11","html_url":"https://github.com/Gama11","followers_url":"https://api.github.com/users/Gama11/followers","following_url":"https://api.github.com/users/Gama11/following{/other_user}","gists_url":"https://api.github.com/users/Gama11/gists{/gist_id}","starred_url":"https://api.github.com/users/Gama11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gama11/subscriptions","organizations_url":"https://api.github.com/users/Gama11/orgs","repos_url":"https://api.github.com/users/Gama11/repos","events_url":"https://api.github.com/users/Gama11/events{/privacy}","received_events_url":"https://api.github.com/users/Gama11/received_events","type":"User","site_admin":false},"created_at":"2017-04-03T20:19:13Z","updated_at":"2017-04-03T20:19:13Z","body":"This seems to be a caching issue. As soon as the filter is applied, the original asset is removed from the cache, causing the subsequent crash when the filter is removed again. `testIcon2` keeps the graphic in the cache, even if it is otherwise unused.\r\n\r\n@Beeblerox I guess the proper fix would be for filters not to remove anything from the cache?"}}
{"actor":{"display_login":"Gama11"}}