{"action":"created","issue":{"url":"https://api.github.com/repos/bkaradzic/bgfx/issues/510","labels_url":"https://api.github.com/repos/bkaradzic/bgfx/issues/510/labels{/name}","comments_url":"https://api.github.com/repos/bkaradzic/bgfx/issues/510/comments","events_url":"https://api.github.com/repos/bkaradzic/bgfx/issues/510/events","html_url":"https://github.com/bkaradzic/bgfx/issues/510","id":105054800,"number":510,"title":"Mismatch between Android threading debug and release","user":{"login":"RichardGale","id":3767708,"avatar_url":"https://avatars.githubusercontent.com/u/3767708?v=3","gravatar_id":"","url":"https://api.github.com/users/RichardGale","html_url":"https://github.com/RichardGale","followers_url":"https://api.github.com/users/RichardGale/followers","following_url":"https://api.github.com/users/RichardGale/following{/other_user}","gists_url":"https://api.github.com/users/RichardGale/gists{/gist_id}","starred_url":"https://api.github.com/users/RichardGale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RichardGale/subscriptions","organizations_url":"https://api.github.com/users/RichardGale/orgs","repos_url":"https://api.github.com/users/RichardGale/repos","events_url":"https://api.github.com/users/RichardGale/events{/privacy}","received_events_url":"https://api.github.com/users/RichardGale/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-05T23:00:46Z","updated_at":"2015-09-11T23:37:51Z","closed_at":null,"body":"Android functions well with threading either enabled or disabled, but when in debug builds the BX_CHECK main thread fails.\r\n\r\nIs this a similar issue to iOS?\r\n\r\nChanging the check in bgfx.cpp:12 appears to work.\r\n\r\n#if BGFX_CONFIG_MULTITHREADED && !BX_PLATFORM_OSX && !BX_PLATFORM_IOS && !BX_PLATFORM_ANDROID\r\n"},"comment":{"url":"https://api.github.com/repos/bkaradzic/bgfx/issues/comments/139687201","html_url":"https://github.com/bkaradzic/bgfx/issues/510#issuecomment-139687201","issue_url":"https://api.github.com/repos/bkaradzic/bgfx/issues/510","id":139687201,"user":{"login":"RichardGale","id":3767708,"avatar_url":"https://avatars.githubusercontent.com/u/3767708?v=3","gravatar_id":"","url":"https://api.github.com/users/RichardGale","html_url":"https://github.com/RichardGale","followers_url":"https://api.github.com/users/RichardGale/followers","following_url":"https://api.github.com/users/RichardGale/following{/other_user}","gists_url":"https://api.github.com/users/RichardGale/gists{/gist_id}","starred_url":"https://api.github.com/users/RichardGale/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RichardGale/subscriptions","organizations_url":"https://api.github.com/users/RichardGale/orgs","repos_url":"https://api.github.com/users/RichardGale/repos","events_url":"https://api.github.com/users/RichardGale/events{/privacy}","received_events_url":"https://api.github.com/users/RichardGale/received_events","type":"User","site_admin":false},"created_at":"2015-09-11T23:37:51Z","updated_at":"2015-09-11T23:37:51Z","body":"Repro with 00-helloworld.\r\n\r\nI added some BX_TRACE around reads and writes to s_threadIndex, the code is running on the render thread but s_threadIndex is set to BGFX_MAIN_THREAD_MAGIC.\r\n\r\nMy interpretation:\r\n\r\n\tContext::init\r\n\r\n\tStarts the render thread, BX_TRACE(\"Creating rendering thread.\");\r\n\r\n\tthread continues and a few lines later\r\n\r\n\ts_threadIndex = BGFX_MAIN_THREAD_MAGIC;\r\n\r\n\tfollowed by more work.\r\n\r\n\tMeanwhile the render thread starts, calls renderFrame() and s_threadIndex does equal BGFX_MAIN_THREAD_MAGIC. Assert.\r\n\r\nMy adb logcat output:\r\n\r\nD/        (27171): BGFX Init...\r\nD/        (27171): src/bgfx.cpp (991): \r\nD/        (27171): BGFX Creating rendering thread.\r\nD/        (27171): src/bgfx.cpp (1000): \r\nD/        (27171): BGFX Running in multi-threaded mode\r\nD/        (27171): src/bgfx.cpp (1002): \r\nD/        (27171): BGFX renderFrame s_threadIndex old 0\r\nD/        (27171): src/bgfx.cpp (1004): \r\nD/        (27171): BGFX renderFrame s_threadIndex new 2019977058\r\nD/        (27171): src/bgfx_p.h (1923): \r\nD/        (27171): BGFX render thread start\r\nD/        (27171): src/bgfx.cpp (825): \r\nD/        (27171): BGFX BGFX_CHECK_RENDER_THREAD s_threadIndex 2019977058\r\nD/        (27171): src/bgfx.cpp (825): \r\nD/        (27171): BGFX CHECK Must be called from render thread.\r\n\r\n\r\nI/DEBUG   (  148): backtrace:\r\nI/DEBUG   (  148):     #00  pc 0005f260  /data/app-lib/com.stuckingeometry.bgfx.example_00_helloworld-2/libexample-00-helloworld.so (bx::debugBreak())\r\nI/DEBUG   (  148):     #01  pc 0005f088  /data/app-lib/com.stuckingeometry.bgfx.example_00_helloworld-2/libexample-00-helloworld.so (bgfx::CallbackStub::fatal(bgfx::Fatal::Enum, char const*)+24)\r\nI/DEBUG   (  148):     #02  pc 000409e8  /data/app-lib/com.stuckingeometry.bgfx.example_00_helloworld-2/libexample-00-helloworld.so (bgfx::fatal(bgfx::Fatal::Enum, char const*, ...)+196)\r\nI/DEBUG   (  148):     #03  pc 00044024  /data/app-lib/com.stuckingeometry.bgfx.example_00_helloworld-2/libexample-00-helloworld.so (bgfx::renderFrame()+132)\r\nI/DEBUG   (  148):     #04  pc 000453f0  /data/app-lib/com.stuckingeometry.bgfx.example_00_helloworld-2/libexample-00-helloworld.so (bgfx::Context::renderThread(void*)+36)\r\nI/DEBUG   (  148):     #05  pc 0000d2e0  /system/lib/libc.so (__thread_entry+72)\r\nI/DEBUG   (  148):     #06  pc 0000d47c  /system/lib/libc.so (pthread_create+240)\r\n"}}