j3k0 / starling-chat-console

A chat console for starling
Apache License 2.0
3 stars 0 forks source link

Stack overflow with very long text #8

Closed j3k0 closed 9 years ago

j3k0 commented 9 years ago

Could it be a starling limitation (?).

Whatever the reason, and if there ain't better fix: a simple one could be to trim the texts to a given reasonable MAX_LENGTH (say 1024)... If trimmed, "..." (three dots) should be added.

When pasting a long text like:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus hendrerit. Pellentesque aliquet nibh nec urna. In nisi neque, aliquet vel, dapibus id, mattis vel, nisi. Sed pretium, ligula sollicitudin laoreet viverra, tortor libero sodales leo, eget blandit nunc tortor eu nibh. Nullam mollis. Ut justo. Suspendisse potenti.

Sed egestas, ante et vulputate volutpat, eros pede semper est, vitae luctus metus libero eu augue. Morbi purus libero, faucibus adipiscing, commodo quis, gravida id, est. Sed lectus. Praesent elementum hendrerit tortor. Sed semper lorem at felis. Vestibulum volutpat, lacus a ultrices sagittis, mi neque euismod dui, eu pulvinar nunc sapien ornare nisl. Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.

Following exception occurs:

Error: Error #1023: Stack overflow occurred.
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()

Another stacktrace one can get while writing a very very long text:

ArgumentError: Error #3683: Texture too big (max is 2048x2048).
    at flash.display3D::Context3D/createTexture()
    at starling.textures::Texture$/empty()
    at starling.textures::Texture$/fromBitmapData()
    at starling.text::TextField/createRenderedContents()
    at starling.text::TextField/redraw()
    at starling.text::TextField/getBounds()
    at starling.display::DisplayObjectContainer/getBounds()
    at starling.display::DisplayObject/get width()
    at fovea.chat.message::UserMessageDisplay/layout()
    at fovea.chat.message::ChatMessage/layout()
    at fovea.chat::ChatConsole/layout()
    at fovea.chat::ChatConsole/addMessage()
    at fovea.chat::ChatConsole/addMessageData()
    at fovea.chat.app::TestHarness/onMessageSent()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at fovea.chat.app.test_data::Server/send()
    at fovea.chat::ChatConsole/onSendReplyText()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/bubbleEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at fovea.chat.reply_window::ReplyWindowDisplay/sendText()
    at fovea.chat.reply_window::ReplyWindowDisplay/onTextChanged()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls::TextInput/set text()
    at feathers.controls::TextInput/textEditor_changeHandler()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::EventDispatcher/dispatchEvent()
    at starling.display::DisplayObject/dispatchEvent()
    at starling.events::EventDispatcher/dispatchEventWith()
    at feathers.controls.text::StageTextTextEditor/set text()
    at feathers.controls.text::StageTextTextEditor/stageText_changeHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at Function/<anonymous>()

The one above is "worst" in the sense that the exception will occur at every frame making the app almost irresponsive. I believe both be solved using the same MAX_LENGTH protection.

JustinWalkerThotkraft commented 9 years ago

You are completely correct, It will be fixed soon.

JustinWalkerThotkraft commented 9 years ago

It has been fixed, I also added a character count to the bottom right of the text window. Set the limit to 256.

j3k0 commented 9 years ago

Okay good.

If I may ask, it would be even better to trim any message displayed on the chat console (also those coming from the server). The chat server doesn't have this 256 length limit, so if someone is using another client to chat with you, it can still break the starling chat client. right?

JustinWalkerThotkraft commented 9 years ago

I didnt think of that but they are going through the same software so they should be restricted by the same limit.However, just as a fail safe in case chat can inputted through another means I will cap the message. My only worry is that a user will send a message and have the full extent not displayed.

JustinWalkerThotkraft commented 9 years ago

The limit for incoming messages has been added.