troubleshooting.rst 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. .. raw:: html
  2. <div id="banner"><a href="https://github.com/jcbrand/converse.js/blob/master/docs/source/setup.rst">Edit me on GitHub</a></div>
  3. =============================
  4. Troubleshooting and debugging
  5. =============================
  6. .. contents:: Table of Contents
  7. :depth: 2
  8. :local:
  9. General tips on debugging Converse.js
  10. =====================================
  11. When debugging converse.js, always make sure that you pass in ``debug: true`` to
  12. the ``converse.initialize`` call.
  13. Converse.js will then log debug information to the browser's developer console.
  14. Open the developer console and study the data that is logged to it.
  15. `Strope.js <http://strophe.im/>`_ the underlying XMPP library which Converse.js
  16. uses, swallows errors, so that messaging can continue in cases where
  17. non-critical errors occur.
  18. This is a useful feature and provides more stability, but it makes debugging
  19. trickier, because the app doesn't crash when something goes wrong somewhere.
  20. That's why checking the debug output in the browser console is so important. If
  21. something goes wrong somewhere, the error will be logged there and you'll be
  22. able to see it.
  23. Additionally, Converse.js will in debug mode also log all XMPP stanzas
  24. (the XML snippets being sent between it and the server) to the console.
  25. This is very useful for debugging issues relating to the XMPP protocol.
  26. For example, if a message or presence update doesn't appear, one of the first
  27. things you can do is to set ``debug: true`` and then to check in the console
  28. whether the relevant XMPP stanzas are actually logged (which would mean that
  29. they were received by Converse.js). If they're not logged, then the problem is
  30. more likely on the XMPP server's end (perhaps a misconfiguration?). If they
  31. **are** logged, then there might be a bug or misconfiguration in Converse.js.
  32. Conflicts with other Javascript libraries
  33. =========================================
  34. Problem:
  35. ---------
  36. You are using other Javascript libraries (like JQuery plugins), and
  37. get errors like these in your browser console::
  38. Uncaught TypeError: Object [object Object] has no method 'xxx' from example.js
  39. Solution:
  40. ---------
  41. First, find out which object is referred to by ``Object [object Object]``.
  42. It will probably be the jQuery object ``$`` or perhaps the underscore.js object ``_``.
  43. For the purpose of demonstration, I'm going to assume its ``$``, but the same
  44. rules apply if its something else.
  45. The bundled and minified default build of converse.js, ``converse.min.js``
  46. includes within it all of converse.js's dependencies, which include for example *jQuery*.
  47. If you are having conflicts where attributes or methods aren't available
  48. on the jQuery object, you are probably loading ``converse.min.js`` (which
  49. includes jQuery) as well as your own jQuery version separately.
  50. What then happens is that there are two ``$`` objects (one from
  51. converse.js and one from the jQuery version you included manually)
  52. and only one of them has been extended to have the methods or attributes you require.
  53. Which jQuery object you get depends on the order in which you load the libraries.
  54. There are multiple ways to solve this issue.
  55. Firstly, make sure whether you really need to include a separate version of
  56. jQuery. Chances are that you don't. If you can remove the separate
  57. version, your problem should be solved, as long as your libraries are loaded in
  58. the right order.
  59. Either case, whether you need to keep two versions or not, the solution depends
  60. on whether you'll use require.js to manage your libraries or whether you'll
  61. load them manually.
  62. With require.js
  63. ~~~~~~~~~~~~~~~
  64. Instead of using ``converse.min.js``, manage all the libraries in your project
  65. (i.e. converse.js and its dependencies plus all other libraries you use) as one
  66. require.js project, making sure everything is loaded in the correct order.
  67. Then, before deployment, you make your own custom minified build that bundles everything
  68. you need.
  69. With <script> tags
  70. ~~~~~~~~~~~~~~~~~~
  71. Take a look at `non_amd.html <https://github.com/jcbrand/converse.js/blob/master/non_amd.html>`_
  72. in the converse.js repo.
  73. It shows in which order the libraries must be loaded via ``<script>`` tags. Add
  74. your own libraries, making sure that they are loaded in the correct order (e.g.
  75. jQuery plugins must load after jQuery).
  76. Performance issues with large rosters
  77. =====================================
  78. Effort has been made to benchmark and optimize converse.js to work with large
  79. rosters.
  80. See for example the benchmarking tests in `spec/profiling.js
  81. <https://github.com/jcbrand/converse.js/blob/master/spec/profiling.js>`_ which
  82. can be used together with the `profiling features of
  83. Chrome <https://developer.chrome.com/devtools/docs/cpu-profiling>`_ to find
  84. bottlenecks in the code.
  85. However, with large rosters (more than 1000 contacts), rendering in
  86. converse.js slows down a lot and it may become intolerably slow.
  87. One simple trick to improve performance is to set ``show_only_online_users: true``.
  88. This will (usually) reduce the amount of contacts that get rendered in the
  89. roster, which eases one of the remaining performance bottlenecks.